Live data from Hacker News

No one expects command execution

0x90909090.blogspot.com

61–70 of 88 posts

Re: No one expects command execution

#61
post #21
post #19

Earlier quoted context omitted.

> UNIX got battle-hardened during its college years Is that when it finally gave up making shar archives? For the unitiated: A shar is a "shell archive", or a shell script which (typically) makes heavy use of 'here documents' to do what tarballs do, only they're shell scripts so you have to execute them and then they can potentially execute arbitrary code unless you read through them very closely and actually underst…

I loved shars. It was a carefree time. Nothing to worry about.

Also there used to be services based on

telnet somehost someport | sh

(I remember an IRC client installer script hosted on sci.dixie.edu like that.)

Unfortunately we still have

curl http://somehost/somepath | bash

which is not very safe even if somehost is not malicious.

But it was kind of awesome when the Internet was friendly!

Re: No one expects command execution

#62
post #46

If your ~/.bashrc is a SYMLINK to a bash or sh script, bash will AUTOMATICALLY EXECUTE that script on login. If you give rsync command a source or destination with an unescaped colon, it will read an ENVIRONMENT VARIABLE to figure out a command to run to AUTOMATICALLY CONNECT TO ARBITRARY NETWORK RESOURCES. If you have keys, it will even SKIP PASSWORD ENTRY, and with default Kerberos, it will not only skip password,…

I think the point is that this is an entire class of vulnerability that most people may never have thought about, but could very easily result in some nasty remote code execution and/or privilege escalation via setuid.

Re: No one expects command execution

#63

Earlier quoted context omitted.

But if you're plugging in input like that, couldn't the malicious user just pass in something like && sudo rm -rf / anyway? Which would render the whole point of the article moot.

There's simple ways to "escape" user input (as in, ensure the whole input string is interpreted as a single argument to this program) in ways that ensure you can't do simple &&'s or ;'s and execute a totally different command. But the point of the article is even if it's properly escaped, users can still do malicious things when input is passed to lots of standard UNIX utilities.

What I wish, I wish there was a flag in unicode to declare characters as 'unsafe user input' so that system utilizes and databases can recognize unsafe user input and barf on it.

Re: No one expects command execution

#64

Earlier quoted context omitted.

A movie from the 70s that compares with TWoO and GWTW in stature would be Star Wars, certainly not MPatHG. I find it unremarkable that people today quote SW.

Yeah but even then, you have The Three Stooges, The Marx Brothers, and Charlie Chaplin. All 30s-era comedy groups similar in notoriety to Monty Python.

In high school and college in the 70s, people did not go around quoting the Marx Bros. They were generally regarded as belonging to their grandparents' generation. It's just not like Python quotes today, which seem to be just as pervasive as in the 70s.

Can you even think of a MB quote without looking one up? If I made a pun on one, would you recognize it?

Re: No one expects command execution

#65

Earlier quoted context omitted.

But if you're plugging in input like that, couldn't the malicious user just pass in something like && sudo rm -rf / anyway? Which would render the whole point of the article moot.

There's simple ways to "escape" user input (as in, ensure the whole input string is interpreted as a single argument to this program) in ways that ensure you can't do simple &&'s or ;'s and execute a totally different command. But the point of the article is even if it's properly escaped, users can still do malicious things when input is passed to lots of standard UNIX utilities.

With the GNU tools you can generally use the `--` option to signal that no more options. That combined with quotes is usually enough:

    tar c -- "$directory_to_tar"

Re: No one expects command execution

#66

Earlier quoted context omitted.

It's amazing how many programs that most people would consider "core unix utilities" totally eschew the (alleged) unix philosophy of "do one thing well."

That's probably a GNU thing. GNU's Not Unix, after all.

touché

Re: No one expects command execution

#67
post #48

Hey guys! Did you know you can actually execute a script with date by running date && ./myscript.sh WOW! I better get on going writing my blog post "executing abitrary code with 'date'".

Doesn't count, a setuid date wouldn't get you root with that command.

How many people have setuid tar? Or man, or zip, or git, or ftp?

Re: No one expects command execution

#68
post #63

Earlier quoted context omitted.

There's simple ways to "escape" user input (as in, ensure the whole input string is interpreted as a single argument to this program) in ways that ensure you can't do simple &&'s or ;'s and execute a totally different command. But the point of the article is even if it's properly escaped, users can still do malicious things when input is passed to lots of standard UNIX utilities.

What I wish, I wish there was a flag in unicode to declare characters as 'unsafe user input' so that system utilizes and databases can recognize unsafe user input and barf on it.

It would be a very rare case where a vulnerability related to in-band signalling can be fixed with more in-band signalling.

Re: No one expects command execution

#69
post #46

If your ~/.bashrc is a SYMLINK to a bash or sh script, bash will AUTOMATICALLY EXECUTE that script on login. If you give rsync command a source or destination with an unescaped colon, it will read an ENVIRONMENT VARIABLE to figure out a command to run to AUTOMATICALLY CONNECT TO ARBITRARY NETWORK RESOURCES. If you have keys, it will even SKIP PASSWORD ENTRY, and with default Kerberos, it will not only skip password,…

So what is your opinion of this method of install? http://brew.sh/

Re: No one expects command execution

#70
post #52
post #46

If your ~/.bashrc is a SYMLINK to a bash or sh script, bash will AUTOMATICALLY EXECUTE that script on login. If you give rsync command a source or destination with an unescaped colon, it will read an ENVIRONMENT VARIABLE to figure out a command to run to AUTOMATICALLY CONNECT TO ARBITRARY NETWORK RESOURCES. If you have keys, it will even SKIP PASSWORD ENTRY, and with default Kerberos, it will not only skip password,…

Did this article make you angry? Why do you call it a trainwreck?

The article is literally "If you tell these utilities to execute this script, they'll execute this script". NONE of these should be "unexpected".
Post reply on HN