How to Secure /tmp Directory ?

The /tmp directory which is present in your Linux web hosting server is allowing to attempted attacks. Despite the actual fact that its tasks is just to store the temporary files needed by applications, however users with harmful intentions will exploit an under-protected /tmp directory for executing scripts or bots.

How To Harden the Security Of /tmp Directory ?

Users should take the subsequent measures for hardening the /tmp directory
A. Creating /tmp as a different partition : The /tmp directory has read, write, and execute permissions set to ON, as a default function. This can be the main reason for the servers vulnerability. Y
ou’ll be able to move it over to a different partition altogether rather than letting it be in the root / partition.By doing this, even though an attacker manages to get an access to the /tmp directory, he wouldn’t be able to get an access to the system files.

B. Setting /tmp as non-executable attributes : you’ll be able to make /tmp noexec in /etc/fstab. Once done, you ought to be able to relate it to : /tmp ext3 loop,noexec,nosuid,rw 0 0 . you will read the distribution documentations to get the suitable settings. it’s recommended to take backup of your server before creating any amendments to the fstab.

C. Installing ModSecurity on server : ModSecurity is an application firewall that helps in protecting the server from different sorts of script exploits that may be found within the web applications. With it, server admins will harden the security of the server, adding an increased protective layer to the network firewall. With this you’d be able to avoid attackers to take advantage of the web scripts, with that they will gain access to the /tmp.

D. Refraining the use of /tmp for web scripts: Incase if the applications are exposed to the web, you’ll be able to select for using a wholly separate and in addition secure temporary directories. you’ll be able to set fewer permissions to it.

By making these modifications to the default settings, you need to make sure that none of the applications that are in operation over the server face a negative impact. Further, some could face a difficulty whereby the hosting control panels like the cPanel may not be able to work with efficiency once implementing some of the above settings and amendments.