Live data from Hacker News

No one expects command execution

0x90909090.blogspot.com

1–10 of 88 posts

Re: No one expects command execution

#2
I don't get it, it's not really unexpected if you pass the name of the executable (which just happens to be a script) via a flag... used explicitly for passing an executable to run.

I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?

Re: No one expects command execution

#3
post #2

I don't get it, it's not really unexpected if you pass the name of the executable (which just happens to be a script) via a flag... used explicitly for passing an executable to run. I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?

I agree. Every single example in this article makes perfect sense to me.

Re: No one expects command execution

#5
post #2

I don't get it, it's not really unexpected if you pass the name of the executable (which just happens to be a script) via a flag... used explicitly for passing an executable to run. I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?

I think he wants to bring to peoples attention that if you give someone sudo rights for a specific program chances are that they will be able to elevate their privilegies.

Re: No one expects command execution

#7
post #2

I don't get it, it's not really unexpected if you pass the name of the executable (which just happens to be a script) via a flag... used explicitly for passing an executable to run. I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?

I guess the author's point is don't ever, ever, ever mix shells and unsanitized user inputs, even if you think it can't possibly be harmful.

In other words, even if it's not obvious, doing this creates a security vulnerability:

    tar bla bla ${user input}

Re: No one expects command execution

#8

Are there any real examples of how this could be used to do something malicious?

Probably strictfp's example above of allowing someone to run specific commands with sudo.

In the past there were also various implementations of a "restricted shell"; it's conceivable that some of these could bypass a restricted shell's restrictions, depending on how they were implemented.

Re: No one expects command execution

#9
post #2

I don't get it, it's not really unexpected if you pass the name of the executable (which just happens to be a script) via a flag... used explicitly for passing an executable to run. I mean, is it unexpected if `./my_command --execute-this-right-now=somescript.sh` executes somescript.sh?

It isn't much different from something like

    echo `somescript.sh`

Re: No one expects command execution

#10

Are there any real examples of how this could be used to do something malicious?

Sure: any attempt to build a "sandboxed" command line interface with a shell, or any web app that shells out to one of these commands and passes user input as an argument.
Post reply on HN