News for hackers. Stuff that matters.
Re:Another ShellShock exploit in the wild by yebyen on Thursday September 25, 2014 @11:57AM (#8367804)
> explain to me how this is any worse than any remote execution vulnerability in something like PHP?

Why does it need to be worse than something you might find in PHP? If it's a worm that's been found in the wild spreading by exploiting a remote execution vulnerability in bash and cgi, isn't that bad enough?

Re:Another ShellShock exploit in the wild by mhurron on Thursday September 25, 2014 @12:04PM (#8367850)
> Why does it need to be worse than something you might find in PHP?

Because that's what it's being hyped as, or more correctly hyped as "OH MY GOD IT'S THE END OF EVERYTHING" when in reality it appears that if you're not running ssh with forcecommands or a webserver with CGI enabled, you don't care, just like if you didn't run a webserver with PHP enabled a PHP vulnerability wouldn't really be much of an issue to you.

Re:Another ShellShock exploit in the wild by drvdevd on Thursday September 25, 2014 @12:27PM (#8367996)
Think of it this way: this doesn't just affect webservers. It affects most unpatched bash instances. The vector of attack is through environment variables in bash. You could argue that 90% of the worlds' PHP servers will probably contain bash, but that the converse is not true: 100% of the worlds' bash instances may not contain PHP. Therefore, the attack surface is much larger and the attack vector much more basic to the way the OS works. Since environment variables are so "leaky" -- they are often spread between processes without any sort of checks -- there are essentially innumerable ways for an exploit to reach a vulnerable version of bash, both remotely and offline.
Re:Another ShellShock exploit in the wild by mhurron on Thursday September 25, 2014 @12:34PM (#8368037)
> It affects most unpatched bash instances

But it needs something to expose bash to the outside world. Without mod_cgi (or the like) or sshd with a specific configuration, a vulnerable bash isn't going to be remotely exploitable.

Re:Another ShellShock exploit in the wild by nitrogen on Thursday September 25, 2014 @12:48PM (#8368116)
No, it doesn't. Bash is already indirectly exposed to the world by anything that calls system() with bash as /bin/sh. More library functions than you might expect are wrappers around external binaries (e.g. mail() calling /usr/bin/mail) on PHP, Ruby, etc. Their authors probably thought they were safe with escapeshellarg()-like functions, but now any user-controlled env var set for whatever reason, not just CGI, is an attack vector, and not just through HTTP and not just through headers.
Re:Another ShellShock exploit in the wild by skuhn on Thursday September 25, 2014 @01:30PM (#8368350)
It is correct that PHP's mail() function will fork a shell:

  sendmail = popen(sendmail_cmd, "w");
Which calls /bin/sh to execute sendmail_cmd. However, two things must also be true:

1. /bin/sh is bash

2. PHP has set environment variables with user-provided data

#1 is often the case, but is much less common now than in the past.

#2 is not commonly the case, PHP does not even automatically create PHP variables from user-provided data anymore (because it is a terrible idea to put untrusted data into a trusted scope without sanitizing).

Re:Another ShellShock exploit in the wild by mhurron on Thursday September 25, 2014 @04:04PM (#8369426)
> It is correct that PHP's mail() function will fork a shell:

> sendmail = popen(sendmail_cmd, "w");

> Which calls /bin/sh to execute sendmail_cmd.

Are you sure? It looks like (at least by default) sendmail_cmd is a string constructed by putting sendmail_path (from php.ini) together with the various options passed to mail(). For most *NIX sendmail_path is going to be /usr/sbin/sendmail and so would execute /usr/sbin/sendmail -t -i [email protected] 'message string'

Re:Another ShellShock exploit in the wild by skuhn on Thursday September 25, 2014 @04:08PM (#8369454)
I haven't tried it, but that is the relevant line from the PHP C source. sendmail_cmd is a variable, so you're right, it will be expanded to whatever.

popen()'s man page says:

  FILE *popen(const char *command, const char *type);
  
  [..]
  
  The command argument is a pointer to a null-terminated
  string containing a shell command line. This command is
  passed to /bin/sh using the -c flag
  
  [..]
Which is where /bin/sh gets involved. PHP should be calling pipe/fork instead of popen IMO, I can't see the point in invoking a shell.
Re:Another ShellShock exploit in the wild by nitrogen on Friday September 26, 2014 @12:37AM (#8371349)
Which is where /bin/sh gets involved. PHP should be calling pipe/fork instead of popen IMO, I can't see the point in invoking a shell.

Ideally there would be something like a popenve() to simplify the process of opening the pipe(s) and passing arguments and environment.

There are also various other variations on the popen() concept, like my own popen3() implementations in C[0] (note that I'm not the only person to write a popen3; Python, Ruby, and probably other languages have their own).

However, I mimicked the real popen(), and my implementation uses /bin/sh as well. It would be easy to make a version of popen3() that accepts argument and environment arrays, but it would still be insecure if the environment was set to the calling process's environ pointer[1], and/or the command to be executed was a /bin/bash script.

[0] https://gist.github.com/nitrogenlogic/1022231#file-popen3_20... [1] http://linux.die.net/man/7/environ

Re:Another ShellShock exploit in the wild by mverwijs on Thursday September 25, 2014 @02:48PM (#8368905)
Well, this is the first time I'm glad /bin/sh on Ubuntu got switched to 'dash'! (Assuming that dash is safe....)
Re:Another ShellShock exploit in the wild by skuhn on Thursday September 25, 2014 @03:15PM (#8369109)
Likewise, it's been a thorn in my side up until now.

And it is safe, POSIX sh does not support exported functions, that is a bash-ism.

Re:Another ShellShock exploit in the wild by general_failure on Thursday September 25, 2014 @12:14PM (#8367922)
Yeah, I am not sure why there is so much hype.

From what I can tell you are affected only if you use CGI or the like somewhere in your response chain. AFAIK most people use http reverse proxies, phpfm, wsgi and the like. They are all unaffected.

Re:Another ShellShock exploit in the wild by nitrogen on Thursday September 25, 2014 @12:36PM (#8368048)
It is not just CGI. It is any process that uses user-controlled environment variables anywhere, that later eventually happens to call something that calls something that calls system() or executes a shell script.

So CUPS printer servers at universities may be vulnerable. Dhclient may be vulnerable to malicious DHCP responses. Anything that calls out may be vulnerable (lots of mail libraries actually call /usr/bin/sendmail or the like; better hope they don't use system() or a bash /bin/sh to do it).

This is a big deal because there's a ton of stuff that uses environment variables that is and is not a web server, and very little time to track it all down before a black hat or oppressive regime gets there first.

Re:Another ShellShock exploit in the wild by epochwolf on Thursday September 25, 2014 @12:20PM (#8367963)
There's a lot of older web applications that run via cgi.