Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relying on PATH to find executables is a security hole. #3

Open
vampirechicken opened this issue Mar 5, 2012 · 4 comments
Open

Relying on PATH to find executables is a security hole. #3

vampirechicken opened this issue Mar 5, 2012 · 4 comments

Comments

@vampirechicken
Copy link

Use full paths to executables.

If you don't provide a full path to the executable, you execute the first one on the path.

$ cat <<EOF > /tmp/head
echo 'Problem?'
EOF
$chmod +x /tmp/head
$ export PATH=/tmp:$PATH 

Now run a program that calls 'head' instead of '/full/path/to/head

You'll run /tmp/head.

If you combine this with setuid/setgid, you have an escalation of privileges waiting to happen.

See also: level one of Stripe Capture the Flag

@seamusabshere
Copy link
Owner

hi,

What if there was something like...

UnixUtils.paths[:cut] = '/my/path/to/cut'

?

Best,
Seamus

@vampirechicken
Copy link
Author

That is how it should be. Full path to executable == not using $PATH == one less well-known vulnerability.

I completely understand why you'd go for the pathless method. You basically need to add a configure script to go out and find all the programs, or make the person installing the gem configure it by hand.

@vampirechicken
Copy link
Author

But, with the Linux File System Standards, it shouldn't be an overly big deal to track down where the executables live.

@rossmeissl
Copy link

That's a good idea -- check all the reasonable places on startup, in order of reasonableness, allow configuration override, and die if something's nowhere to be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants