This article is more than 1 year old

Patch Bash NOW: 'Shellshock' bug blasts OS X, Linux systems wide open

CGI scripts to DHCP clients hit by Heartbleed-grade remote-code exec vuln

Updated A bug discovered in the widely used Bash command interpreter poses a critical security risk to Unix and Linux systems – and, thanks to their ubiquity, the internet at large.

It lands countless websites, servers, PCs, OS X Macs, various home routers, and more, in danger of hijacking by hackers.

The vulnerability is present in Bash up to and including version 4.3, and was discovered by Stephane Chazelas. It puts Apache web servers, in particular, at risk of compromise: CGI scripts that use or invoke Bash in any way – including any child processes spawned by the scripts – are vulnerable to remote-code injection. OpenSSH and some DHCP clients are also affected on machines that use Bash.

Ubuntu and other Debian-derived systems that use Dash exclusively are not at risk – Dash isn't vulnerable, but busted versions of Bash may well be present on the systems anyway. It's essential you check the shell interpreters you're using, and any Bash packages you have installed, and patch if necessary.

"Holy cow. There are a lot of .mil and .gov sites that are going to get owned," security expert Kenn White said on Wednesday in reaction to the disclosed flaw.

The 25-year-old bug, dating back to version 1.03, lies in Bash's handling of environment variables: when assigning a function to a variable, trailing code in the function definition will be executed, leaving the door wide open for code-injection attacks. The vulnerability is exploitable remotely if code can be smuggled into environment variables sent over the network – and it's surprisingly easy to do so.

According to the NIST vulnerability database, which rates the flaw 10 out of 10 in terms of severity:

GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution.

Authentication: Not required to exploit

Impact Type: Allows unauthorized disclosure of information; Allows unauthorized modification; Allows disruption of service

An advisory from Akamai explains the problem in more depth, as does this OSS-Sec mailing list post.

Proof-of-concept code for exploiting Bash-using CGI scripts to run code with the same privileges as the web server is already floating around the web. A simple Wget fetch can trigger the bug on a vulnerable system.

You can check if you're vulnerable by running the following lines in your default shell, which on many systems will be Bash. If you see the words "busted", then you're at risk. If not, then either your Bash is fixed or your shell is using another interpreter.

env X="() { :;} ; echo busted" /bin/sh -c "echo completed"
env X="() { :;} ; echo busted" `which bash` -c "echo completed"

Jim Reavis, chief exec of the Cloud Security Alliance, claims the hole is comparable in seriousness to the infamous password-leaking Heartbleed bug in the OpenSSL library that was uncovered earlier this year.

"A large number of programs on Linux and other UNIX systems use Bash to setup environmental variables which are then used while executing other programs," Reavis explained in a blog post.

"Examples of this include web servers running CGI scripts and even email clients and web clients that pass files to external programs for display such as a video file or a sound file.

"In short this vulnerability allows attackers to cause arbitrary command execution, remotely, for example by setting headers in a web request, or by setting weird MIME types."

Robert Graham of Errata Security, who suggested the name Shellshock for the Bash flaw, also said the programming cock-up is as severe as Heartbleed. But he noted: "There's little need to rush and fix this bug. Your primary servers are probably not vulnerable to this bug.

"However, everything else probably is. Scan your network for things like Telnet, FTP, and old versions of Apache (masscan is extremely useful for this). Anything that responds is probably an old device needing a bash patch. And, since most of them can't be patched, you are likely screwed.

"A lot of wireless routers shell out to ping and traceroute – these are all likely vulnerable."

The vulnerability (CVE-2014-6271) affects Apple's OS X – and is useful for privilege escalation – as well as major flavors of Linux. Fortunately, patches are already available, and distros are ahead of the game in responding to the flap. BSD distros that do not use Bash are safe, obviously. Apple users will need to get their hands dirty until Cupertino issues a fix.

Red Hat security engineer Huzaifa Sidhpurwala has a rundown of the at-risk software, here. ®

Updated to add

Linux vendor Red Hat has warned the patch to fix Bash is not complete, and there are still ways to inject commands via environment variables. In an update at 0310 GMT, Red Hat said:

Red Hat has become aware that the patch for CVE-2014-6271 is incomplete. An attacker can provide specially-crafted environment variables containing arbitrary commands that will be executed on vulnerable systems under certain conditions. The new issue has been assigned CVE-2014-7169. Red Hat is working on patches in conjunction with the upstream developers as a critical priority.

More about

TIP US OFF

Send us news


Other stories you might like