I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?
I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?
In other words, even if it's not obvious, doing this creates a security vulnerability:
tar bla bla ${user input}It does:
irb(main):001:0> gets.tainted?
foo
=> true
You can even set $SAFE to 1 or higher to disallow the use of tainted strings in potentially dangerous commands: freya:~ flgr$ ruby -e '$SAFE = 1; system "tar bla bla #{gets}"'
foo
-e:1:in `system': Insecure operation: -r (SecurityError)
from -e:1:in `<main>'
See http://phrogz.net/programmingruby/taint.html for more information.Yes, it does. E.g:
x = STDIN.gets
puts x.tainted?
y = "hello "+x
puts y.tainted?
z = "foo"
puts z.tainted?
The two first will return "true", and the last will print "false". If you set the safe-level appropriately some methods will be disallowed for x and y above (e.g. eval()), though I would not trust that as comprehensive, but it's a lot better than nothing. && sudo rm -rf /
anyway? Which would render the whole point of the article moot.Just to make sure you are on the same page as the rest of us here: in-band and out-of-band is a way to distinguish sending meta information about the data stream through the same channel as the original data. You need an escape mechanism for that, so control characters and such.
Out-of-band signalling indicates that all meta information about the data stream travels through a different (virtual) circuit, in which case there can never be confusion about whether a given chunk is data or meta info.
tar c -- "$directory_to_tar"For those sysadmins, yeah, it's unexpected.
the most determined of attackers will always find a way in.
Did you read the manpage of every utility on your computers to know that they won't execute a user supplied program? If you didn't you are up to nasty surprises.
That $HOME trick alone would give privilege escalation to anybody that gets a user-level access to a server of mine. Gota change it.
echo `somescript.sh`