Linux – Managing /tmp and /var/tmp, and why not globally writeable

linuxSecurity

Ive been trying to lock some security vulnerabilities at my server, and I got to the point of the tmp folders. Both of them will store files that are used by other resources, still, reading a little more I found out that the /tmp could save some data that involves the server itself instead of the /var/tmp.

My question is, What are the implications of securing write access to /tmp and /var/tmp. I already tried securing /var/tmp and until now nothing bad has happened.

Is it safe to block /tmp and deny saving files that could damage my server or could there be a type of spam or something similar that affects my security? What is the vulnerability if I allow access on my server to these folders, say writeable with 777 permissions (like they come by default)

Thanks

Best Answer

/tmp and /var/tmp are supposed to be world-writable so that all programs/users can create their temporary files there. The sticky bit ensures that only the owner (and root of course) can move/rename/delete the file (see chmod(1)). Of course an application could still set insecure permissions on files, allowing read- or write-access to the wrong user(s), but that's up to the application and has nothing to do with the permissions on those directories.