Snippets tagged "security linux sysadmin" Snippets tagged "security linux sysadmin"

Sécuriser /tmp

Beaucoup de script-kiddies s'amusent beaucoup avec le répertoire /tmp, par défaut aisément accessible et donc réceptacle à executables falacieux de tous poils.

Voici une méthode permettant de remplacer ce point de montage par un nouveau, de 40Mo mais dont la particularité sera de ne pas autoriser l'execution de programmes (héhé) :

# create a 40MB block device which will be the /tmp file system
cd /root
dd if=/dev/zero of=/root/tmpMnt bs=1024 count=40000
mkfs.ext3 -F /root/tmpMnt
# mount it at /tmp
mv /tmp /tmp.backup
mkdir /tmp
mount -o loop,noexec,nosuid,rw /root/tmpMnt /tmp
chmod 0777 /tmp
# make it so it is used on boot up
if ! grep -qai tmpMnt /etc/fstab ; then 
     echo "/root/tmpMnt /tmp ext3 loop,noexec,nosuid,rw  0 0" >> /etc/fstab
fi
# check your syntax is ok
mount -a
# check that programs in /tmp will not run
cp /bin/ls /tmp/
/tmp/ls

Pour remonter /tmp avec droits d'execution :

# umount /tmp
# mount -o loop,rw /root/tmpMnt /tmp

Et remonter la partition sans les droits d'execution :

# umount /tmp
# mount -o loop,noexec,nosuid,rw /root/tmpMnt /tmp
by Nicolas Perriault on 2007-02-05, tagged linux  security  sysadmin