Avoiding Interpreter Spoofing

Problem

You want to avoid certain kinds of setuid root spoofing attacks.

Solution

Pass a single trailing dash to the shell, as in:

#!/bin/bash -

Discussion

The first line of a script is a magic line (often called the shebang line) that tells the kernel what interpreter to use to process the rest of the file. The kernel will also look for a single option to the specified interpreter. There are some attacks that take advantage of this fact, but if you pass an argument along, they are avoided. See http://www.faqs.org/faqs/unix-faq/faq/part4/section-7.html for details.

However, hard-coding the path to bash may present a portability issue. See Finding bash Portably for #! for details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.241.82