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: 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.

    Starting Score:    1  point
    Moderation   +1  
       Informative=1, Total=1
    Extra 'Informative' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3  
  • (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!