Remote Exploit Vulnerability Found In Bash
kdryer39 sends this news from CSO: A remotely exploitable vulnerability has been discovered by Stephane Chazelas in bash on Linux, and it is unpleasant. The vulnerability has the CVE identifier CVE-2014-6271. This affects Debian as well as other Linux distributions. The major attack vectors that have been identified in this case are HTTP requests and CGI scripts. Another attack surface is OpenSSH through the use of AcceptEnv variables. Also through TERM and SSH_ORIGINAL_COMMAND. An environmental variable with an arbitrary name can carry a nefarious function which can enable network exploitation.
I'm not suprised; Bash has always felt a bit dangerous...
https://marc.info/?l=oss-security&m=141157106132018&w=2
-=/\- Jizzbug -/\=-
Because we've finally become popular enough to warrant script kiddies finding holes in our toys!
Captcha: Outcry
I can't find the bash icon in the Start menu. Anyone know where it is so I can remove it and avoid this exploit?
Thanks.
sudo yum update bash
Thank you for the quick warning.
So, if I undestand correctly, this affects shell scripts used for CGI; do people actually do that on what scale?
Only person I know who does this is a CS teacher in my college, onhis homepage which he has had since early 90s, are there actually commercial installations which do this, some major product with large install base ("asking this for my son")?
Linky
"National Security is the chief cause of national insecurity." - Celine's First Law
Thanks god I am using windows.
Bash.org is dead. Even net craft confirmed it.
i thought once I was found, but it was only a dream.
This is the test to see if you are vulnerable:
:;}; echo vulnerable' bash -c "echo this is a test"
env x='() {
"The price good men pay for indifference to public affairs is to be ruled by evil men." ~Plato (427-347 BC)
All the systems I've done security pen tests against that were using bash for CGI were so easy to hack via other means it wasn't funny. And of course that web server CGI was running as root so root shell and done.
Stop using Bash for CGI unless you want to get pwned. Similar theme with 90% of the Perl CGI I run into.
My favorite of this sort of thing is CVE-2009-1717, which was a bug in Apple's terminal emulator in Mac OS X. Sending certain escape sequences to it caused it to blow up and potentially execute code. What was fun is that putting a "telnet://" link in a web page would automatically cause Mac OS X to automatically open a terminal and connect to a remote host with no prompting by the user. It was a pretty neat vulnerability.
...but it's being eaten...by some...Linux or something...
Has Netcraft unconfirmed the death?
Someone correct me if I'm mistaken, but doesn't this exploit depend on programs not validating input?
The example given in the post to oss-security mentions HTTP request headers containing malicious data being passed into CGI programs which then call out to Bash. Wouldn't taint-checking input eliminate that attack vector?
Because MS hates standards. Their first vowel for exploitable software is 'i'. If you think that doesn't hold up, prepend Microsoft or Windows.
clowns please pipe down.
this seems a simple error to actually fix, so why is everybody fapping off about this thing, and not fixing it?
or did i miss the patch?
i'm actually hoping for a reply here, sorry if i missed the meeting, otherwise will be applying my own patch, very quickly.
i rely on bash and it's isms, it's a good thing, and ought to be more of a standard.
So far, HTTP requests to CGI scripts have been identified as the major
attack vector.
Umm.. who still does that? That sounded wonky, risk-prone, and a hack in the mid 90s. Who's still using CGI scripts to execute shell code?
AccountKiller
Well, that's OK. i is like a for large enough values of a (or really small values of i).
And depending on what part of the world you're in, the sound of vowels can change quite a bit.
A few years back, my wife's mother and some friends were in the southern US ... she walked into the store and asked if they have any pins ... the cashier asked if she "wanted a ball point pin or a fountain pin". I kid you not.
In fact, my wife had an economics prof from Texas once. There was no discernible difference between the sound of "microeconomics" and "macroeconomics", because apparently a and i have the same value there.
Therefore, in Texas, your statement is 100% true. ;-)
Lost at C:>. Found at C.
(nt)
Yes, because it's not a Linux hole. GNU Bash is the vulnerable software. So if you have Bash installed, you're vulnerable (I'm about to test the vulnerability myself).
I'm starting to think GNU is the problem with "GNU/Linux" these days.
You can get shell on git@ accounts set up with gitolite and gitosis, at least some of their versions will use /bin/bash as the login shell (and only use ~/.ssh/authorized_keys to restrict the commands). One easy way to check whether your git server account is vulnerable:
ssh git@yourgitserver '() { echo $1; }; /usr/bin/id'
It's not the fall that kills you. It's the sudden stop at the end. -Douglas Adams
Who does CGI with anything but a restricted shell these days? And should we shoot them now, or after they fix their scripts?
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
VAR=() { ignored; }; : :(){ :|:& };:
#include bier;
The environment bashes you for 99 Hit Points! You are dead.
Obviously you've never used Linux in the wild.
> Someone correct me if I'm mistaken, but doesn't this exploit depend on programs not validating input?
Suppose you have pwd.cgi, which prints the name of the current directory:
#!/bin/sh
echo -e "Content-type: text/plain\n\n"
pwd
Notice the script uses no input at all. It is potentially vulnerable. Here's why. Suppose you did want to validate your input. You'd look at the contents of $QUERY_STRING, right? You can find what the user entered in the QUERY_STRING environment variable because bash puts it there. That's the step where the problem lies - bash can EXECUTE the contents of the query string while setting the environment variable. This occurs before the user's script even begins to run.
app-shells/bash-4.2_p47-r1 is not vulnerable. I just updated.
Many, many sites have one line scripts like this laying around:
#!/bin/sh
echo -e "Content-type: text/plain\n\n"
df -h
Or similarly, a script that just runs pwd or uptime.
Why do people say/write "environmental" variable? I've never seen the that word used in shell documentation or any literature on *nix written by competent authorities. It's "environment variable."
It's due to global warming.
Sure, but what about 'Gates'? ;-)
This space intentionally left blank
> Oh I had the same thought....I mean, by the time an "attacker" is modifying arbitrary environment variables in your process, well...you are already pretty compromised. If you wrote your CGI, then you are the one that compromised yourself.
The contents of the CGI script don't matter. The exploit occurs before the script runs. It happens as bash is setting up the environment in which the script will be run.
Suppose you have pwd.cgi, which prints the name of the current directory:
#!/bin/sh
echo -e "Content-type: text/plain\n\n"
pwd
Notice the script uses no input at all. It is potentially vulnerable. Here's why. Suppose you did want to validate your input. You'd look at the contents of $QUERY_STRING, right? You can find what the user entered in the QUERY_STRING environment variable because bash puts it there. That's the step where the problem lies - bash can EXECUTE the contents of the query string while setting the environment variable. This occurs before the user's script even begins to run.
From the CVE, I'm pretty sure the problem isn't limited to CGI written in Bash. The problem affects any CGI that *calls* bash, which means any call to system() in any language is going to cause a problem.
$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
this is a test
$ bash --version
bash --version
GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
This is from my Debian stable box.
Is that good or bad? :O
Ant(Dude) @ Quality Foraged Links (AQFL.net) & The Ant Farm (antfarm.ma.cx / antfarm.home.dhs.org).
Actually no, that comment does not explain either of the two key points, a) it happens before script is executed and most importantly b) it therefore is independent of the content of the script.
Nice try though, apk.
Almost *ANY* CGI is vulnerable, because the way CGI works is by environment variables. And the attacker can control them. You don't have to be doing anything stupid or wrong to be affected. It looks like other ways of executing web applications (e.g., mod_php) are safe - to the extent that they don't use a popen or a system() or something, which is a pretty common thing to do.
Your DHCP client (on a Linux) machine passes data to its hooks via environment variables. These can be set by the attacker. Even better, it's running as root. Boom, connect to a rogue AP and get rooted while receiving an address assignment.
You probably do Git commits via a (locked-down) SSH login. That's compromised.
Shells are everywhere. Again, this doesn't require your application to have screwed up. This is a flaw in how environment variables are parsed and set, which is something that was presumed safe, so nobody thought about it. Bad bad bad bad. Not Heartbleed bad, but close.
I have developed a truly marvelous proof of this comment, which this signature is too narrow to contain.
Sure, but anything remote that can set up environment variables before starting bash can exploit it. Lots of idiot programmers like to blindly shell out to do stuff even when there's a simple library function to do things, such as unlink("$path") vs. system("rm $path"). And environment variables have this pesky habit of sticking around when you do that. Environment variables are commonly used with CGI, which is also commonly used with idiot programmers. So while it may be a "local" exploit, that's with unusually large values of "local".
#naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
Debian and ubuntu have been patched by the security team 4 hours ago (more or less when this article has been written).
This is bad. The reason is lots of things that use bash put unchecked data into environment variables.
As an example, imagine some cgi wants to test is a string is valid, and somebody wrote a clever bash script that does this check, and reads the string by looking in $INPUT. The cgi takes whatever the user typed on their web form, does setenv("INPUT", text) and then runs the bash script, which uses "$INPUT" at places it wants the text.
No matter how carefully written the bash script is, if the user can type "() { :;}; exploit" into the text field, it will run "exploit". There is no reason for the cgi to test for any syntax errors because that is the job of the bash script!
It seems hard to believe such a bug is possible. It appears that when setting an environment variable, if it is a function, it runs some code that splits the text at semicolons, puts the first section in the environment variable, then runs the rest as shell input! But I can't figure out any reason such code exists. I thought at first it was pasting "export " on the start of the environment line and executing that using the interpreter, but tests show that does not work because it splits at the spaces. And if you add quoting to fix that then it also fixes the semicolon. And it obviously examined the environment variable to see if is a function, because semicolons in non-function ones are handled correctly. So I think bash code might be quite a mess for such a bug to be possible without much more obvious bugs happening...
ah but in Texan micro is just two syllables "my-crow" while macro is three "my-yah-crow". Hope that helps.
ok I made that shit up
That's good. The version number means nothing since Debian backported the fix rather than upgrading bash completely, but the check above didn't say vulnerable so you're clear.
sudo mv /bin/bash /bin/woosh
It's a big issue if you're using locked-down ssh, for example in a git server.
Thank you, sir. Good job to Debian team on releasing the fix!
Ant(Dude) @ Quality Foraged Links (AQFL.net) & The Ant Farm (antfarm.ma.cx / antfarm.home.dhs.org).
php-fpm uses the fastcgi protocol, which is not the same as cgi and therefor not vulnerable.
sudo aptitude update;
sudo aptitude safe-upgrade;
done.
Uh, Linux geek since 1999.
check your updates repository to make it is enabled and a CentOS official repo. .repo file for it, the update was found.
Even though it often isn't set to enabled, oddly when I put enabled=1 in my
Am I wrong but that this exploit only works if you are running CGI scripts? Am I also wrong in thinking that if you are running PHP as an Apache Mod that this exploit doesn't work unless you are executing command line stuff?
Also the SSH aspect seems to be more of a privilege problem whereby someone has to have a valid ssh account before they can start hacking?
I am going to go out on a limb and say, if you are using CGI you are a dumbass and if you give anyone who you can't trust with ssh then you are also a dumbass. I don't think that I have configured a CGI serving machine since last millennia (literally).
Would something like this work? "avoir && ln -s /usr/bin/whoami /usr/bin/quisuis-je && quisuis-je"
Example attacks are listed on Red Hat's security blog.
I'm sorry, I've meant to link to http://seclists.org/oss-sec/20... (you may want to walk the thread up a bit) and https://bugzilla.redhat.com/sh...
It's not the fall that kills you. It's the sudden stop at the end. -Douglas Adams
While bash is by far my favourite UNIX shell, I've seen various bits of evidence that have indicated a need for major refactoring, for quite a while now. I would look into it myself, but there is always the risk that whatever changes I proposed would be rejected. Perhaps I should think about creating a fork, although that would be a lot of work.
Just having Bash installed does not make a system vulnerable. In order for the system to be vulnerable you also need to provide a method for a remote party to pass an environment string to the Bash shell. This would typically be handled via CGI when the web server hands GET and POST data via an environment variable to a Bash script. I do not believe Apache call to Bash for launching a Perl based CGI script so the global attack surface should be pretty small. I do not think I have seen a Bash CGI script since the 90's.
-rd
No.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
LOL ... I gather it was more like "mah-cro" and "mah-cro".
Lost at C:>. Found at C.
Look, there is a bug, obviously, but to say that it is "remotely exploitable" is a half-truth, and that it is "on level with or worse than heartbleed" is nonsense.
There are a lot of things that need to "line up" in order for this to be remotely exploitable.
echo '[q]sa[ln0=aln80~Psnlbx]16isb572CCB9AE9DB03273snlbxq' |dc
It seems that the Hiawatha webserver is not vulnerable for this exploit, because it doesn't URL decode environment variables. Wise decision (CGI's seem to work fine without it) or just luck? Is there a standard which says that CGI environment variables should be URL decoded?
It doesn't have to be like this. All we need to do is make sure we keep talking.
Two words - dhcp client. Think how it works on Linux.
Take a look again at the command you just ran. You're still invoking bash.
The problem affects any CGI that *calls* bash, which means any call to system() in any language is going to cause a problem.
Nowadays, on most systems, /bin/sh is a proper Bourne Shell (either ash or dash), and no longer bash. So system() should no longer be an issue, but explicitly calling bash still would be...
I was explaining it to someone (co worker) yesterday as the vulnerability is there, but there needs to be an attack vector open as well. My demo to him was on an SGI system running IRIX - Bash was vulnerable, but without AccetEnv in SSH being enabled or something like Apache CGI the exploit can't be used.
I'm starting to think GNU is the problem with "GNU/Linux" these days.
Earlier this week, there was much cursing in Ft. Meade. Today, there is much cackling in Calgary.
Even if they fix the basic bug, which is that functions are exported as environment variables, but the function can be trailed with extra commands, the whole idea seems extremely dangerous to me. What if you define a function called ls or cp or some other common command? It's pretty likely something will call it, and the whole problem is back in play.
The bigger problem to me seems to be that cgi scripts export user parameters to environment variables before calling bash. I mean, bash itself as a cgi web handler seems incredibly dangerous already. Too powerful for this application. But to then have unvetted user defined environment variables? This is insane. There's plenty of blame to go around here.
Not updated in Debian Squeeze yet, though.
My other account has a 3-digit UID.
what really sux, is that for most people, here in the southern part of the US, no matter how much they want to, they can't hear or speak the difference in pen vs. pin. That why we call them stick pins, and not just pins..
CMD.EXE -- bulletproof!
Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
/bin/sh is frequently a symlink to /bin/bash
# ls -alh /bin/sh /bin/sh -> bash
lrwxrwxrwx. 1 root root 4 Sep 24 12:47
It also affects bash scripts called from programs run by CGI, so e.g. Perl, python, C, C++ programs using system(). Since environment variables are inherited by all subprocesses, it affects grandchildren, greatgrandchildren, and all the other sub-processes that get created all the way down.
Some scripting and programming languages use the shell to expand "glob" patterns, e,g,
$names = glob( "/tmp/[0-9]*" )
or in other places where it may not be obvious.
I'm not interested in comparing numbers of holes in different systems as it ony takes one hole for an intruder to get in.
Live barefoot!
free engravings/woodcuts
dhclient and dhclient-script
and yes, the target machines in that case would be laptops and mobile devices.
For servers, I have read elsewhere that cPanel at least is vulnerable. Not many servers using that, right ?
Bash 1.14.0, see http://web.nvd.nist.gov/view/v...
So, >20 years
That you don't understand it doesn't mean it's not real.
Some people run a program called a "Web server" which listens on a network and runs programs based on requests it receives :-)
It's not about using bash for CGI scripts, although that's an obvious example. Some people use languages like Perl or python or even php (in CGI mode), or C, or Pascal, and all of those programs can be affected too, because they might use something like systm() or `...` or run an external program that in turn calls the shell, directly or indirectly.
Other services are also affected - ssh, dhcp, remote git, potentially even ftp and email although that seems less likely.
Live barefoot!
free engravings/woodcuts
When I execute: env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
on ksh under Sco unix 5.0.7 - it outputs vulnerable
I'm not sure if ksh on other platforms would also be vulnerable (probably)
I'm sorry, I overstated the issue. The command I typed still only exposes the issue in the bash program, not the ksh program. Setting the x=.... function and then invoking bash is an issue, but if you run: env x='() { :;}; echo vulnerable' ksh -c "echo this is a test"
you don't see vulnerable, I'm sorry for the confusion.
At least for RedHat/CentOS, CVE-2014-7169 has been patched now as well. https://rhn.redhat.com/errata/...
"The (ancient) version of bash that ships with OS X appears vulnerable."
Some really ancient versions of OSX shipped not bash but tcsh, which was (is?) the NetBSD default shell. So who's going to write the anti-bash rebuttal to the famous "Top Ten Reasons not to use the C shell": http://www.grymoire.com/unix/C...
It's been in there since Bash 1.4.
Nope can't find any evidence that iPhones ship with a full bash install, but they do have the capability to run some bash commands.
"When information is power, privacy is freedom" - Jah-Wren Ryel
IIF the CGI script is bash based... and WTF do you mean by "binaries" ?
-- 29A the number of the Beast