LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (http://www.linuxquestions.org/questions/linux-security-4/)
-   -   how does mktemp prevent denial-of-service attack (http://www.linuxquestions.org/questions/linux-security-4/how-does-mktemp-prevent-denial-of-service-attack-803484/)

seaker79 04-22-2010 06:16 AM

how does mktemp prevent denial-of-service attack
 
Hello,

This is an excerpt from the Linux man page for mktemp command:
"mktemp is provided to allow shell scripts to safely use temporary files. Traditionally, many shell scripts take the name of the program with the PID as a suffix and use that as a temporary filename. This kind of naming scheme is predictable and the race condition it creates is easy for an attacker to win. A safer, though still inferior approach is to make a temporary directory using the same naming scheme. While this does allow one to guarantee that a temporary file will not be subverted, it still allows a simple denial of service attack. For these reasons it is suggested that mktemp be used instead."

- How can a denial-of-service attack be carried out if a directory name is known?
- Why is it important to use mktemp to generate a sufficiently random file/directory name for temporary files?

Thanks for your answer,
best regards,
Hari

blackhole54 04-22-2010 07:56 AM

Quote:

Originally Posted by seaker79 (Post 3943812)
- How can a denial-of-service attack be carried out if a directory name is known?
- Why is it important to use mktemp to generate a sufficiently random file/directory name for temporary files?

As I understand it, this is a matter of an attacker being able to guess the filename (or directory name) you wish to create and thereby block it by creating it first. I am sure you can come up with complicated scenarios about how this might happen and whether (under what circumstances) it is a problem. But mktemp is trying to bypass all of that by making it extremely unlikely that an attacker could guess the name. There are probably circumstances where this is relatively unimportant while there are other circumstances where it wold be crucial. But with such a tool as mktemp available, why would you want to not use it?


All times are GMT -5. The time now is 01:38 AM.