lately there has been a lot of DOS (Denial of Services) Attacks happening, and one of the main causes of these attacks of because of insecure /tmp directories.
Your /tmp directory is very dangerious, since it allows every single user the ability to write to it, so should you have an upload script on your site that may be exploitable, or even if there is an vulnerability in a program which allows for remote code execution, it will allow the person to upload a file into your /tmp directory or even use remote code execution to take control of something like wget and download something into your /tmp directory (this is usually how DOS trojans and rootkits end up on your server)
But there something you can do to help protect your /tmp directory:
===============================================
Firstly you need to stop all processes that are using your /tmp so you can work with it.
# lsof | grep /tmp
you should see something like this:
# lsof | grep /tmp
mysqld 21592 mysql 6u REG 7,0 0 13 /tmp/ibtSj50S (deleted)
mysqld 21592 mysql 7u REG 7,0 0 14 /tmp/ibRxcWMR (deleted)
mysqld 21592 mysql 10u REG 7,0 0 15 /tmp/ibsqk6gR (deleted)
apache2 21620 root 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 21855 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 21961 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22105 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22372 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22378 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22437 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22510 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22511 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22574 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
apache2 22710 apache 60u REG 7,0 0 16 /tmp/ZCUDqD8qem (deleted)
#
stop those processes which are using your /tmp directory,
then copy and paste the following this into your terminal window:
cd /
dd if=/dev/zero of=/tmpdir bs=1024 count=200000
mkfs.ext3 -F /tmpdir
mv /tmp /tmp.backup
mkdir /tmp
mount -o loop,noexec,nosuid,rw /tmpdir /tmp
chmod 0777 /tmp
if ! grep -qai tmpdir /etc/fstab ; then
echo "/tmpdir /tmp ext3 loop,noexec,nosuid,rw 0 0" >> /etc/fstab
fi
mount -a
cp /bin/ls /tmp/
/tmp/ls
it should return something like this:
-bash: /tmp/ls: Permission denied
If you see that, then you know everything has gone according to plan.
What the above will do, is create a storage medium (so call it) on /tmpdir, and then mount /tmpdir to /tmp, but it will mount it with loop,noexec,nosuid,rw
Still won't stop the rootkits or DOS files from being uploaded or downloaded into ur /tmp directory, but I will sure as hell stop them from being executed.
Hope this helps
kthx
Dave Strydom