Recently, there have been news going around regarding "CVE-2014-6271" (See USN-2362-1), which is a vulnerability in Bash. How do I know if I am affected by this, how can I fix it, and why should I care?
This is designed as a canonical answer for this vulnerability, due to its scope and severity.
What is Bash?
Bash is the default interactive shell in Ubuntu. When you are interfacing with the terminal (either through the terminal emulator, over a tty, or ssh), you are generally typing commands that
bash
will read, and execute. Even if you do not use the terminal at all, you still have Bash.On Ubuntu,
/bin/sh
is not bash (it is dash). Only bash is affected by this vulnerability.How does the exploit affect me?
Bash and the OS keep track of a set of environment variables that describe the current logged-on user, where to look for programs on the hard disk, and other such functions. By crafting an environment variable with a specific structure, an attacker might be able to execute code next time Bash starts.
The attacker can set that environment variable multiple ways:
ForceCommand
option is an attack vector. Accounts whose shell isn't bash aren't affected.Once they set this variable, the next time
bash
opens for any reason, your attacker's code will be run. This is especially fearsome withsudo -s
, as it spawns bash as the super-user (an administrative user rule that has full control over your computer's data and programs). Even if you only start bash as a standard user, that user's files can be deleted.It is important to note that even if you do not use bash yourself, many programs will spawn bash by themselves as part of their operation. Even in this case, you are vulnerable. However, Ubuntu's
/bin/sh
is not bash, so only programs that explicitly invoke bash and not the default scripting shell are affected.According to Mitre:
Am I vulnerable?
Use dpkg to check your installed package version:
This will look up info on your
bash
package, and filter the output to only show you the version. The fixed versions are4.3-7ubuntu1.4
,4.2-2ubuntu2.5
, and4.1-2ubuntu3.4
.For example, I see:
and can determine that I am not vulnerable.
How do I update?
The standard update manager will offer you this update. This is a prime example of how security updates are important, no matter what OS you use or how well-maintained it is.
The USN Bulletin states that new versions have been released for Ubuntu 14.04 Trusty Tahr, 12.04 Precise Pangolin, and 10.04 Lucid Lynx. If you are not on one of these LTS versions, but are on a reasonably-recent version, you'll most likely be able to find a patched package.
First, check if you
If you are vulnerable, you should first grab the newest package lists:
The first command makes sure that you have the newest package list that includes the fixed version, and the second command installs the newest (fixed) version of bash.
While the bug only appears to come into play when bash is spawned, it's still a good idea to reboot immediately if feasible.
Stole this off of cft over at Hacker News. If you have trouble with your repos like me(Odroid-XU), then this should work nicely if you want to patch/build from source.
Then run:
And if you get:
Then you're all good!
WARNING: make install will install bash in
/usr/local/bin
, so/bin/bash
is not modified and can be invoked from curl !!Note: The Security Patch for CVE-2014-7169 has been released as a standard security update. There is no need to add additional ppa's to receive this patch. Only the following is needed.
To ensure you have patched bash correctly, run the following command
If you are on 14.04 LTS, you should see an output of:
If you are on 12.04 LTS, your output should be:
If you are on 11.04: use below steps (it worked for me)
if it is not downloaded required patche then install ftp package
To see if the patch was applied:
I'm using Natty 11.04, which is EOL (and I have updated /etc/apt/sources.list to use old-releases.ubuntu.com), so I have to build from source. I wanted to build a .deb, so at least the package manage is "aware" the bash version is not the default one. I am not 100% succesful - however, the package is registered as "newer" and the
bash
binary ends up fixed, so here is what I did:Now, in the (sub)directory
bash-4.2/
, there is: a filebash-4.2.tar.xz
, which needs to be unpacked to get to thebash
source; and a subdirectory calleddebian
.I made the following changes to avoid dependencies on
texlive
: inbash-4.2/debian/control
:... and in
bash-4.2/debian/rules
:To change the version, in this
bash-4.2/
directory, do:... and fill in the notes in the changelog when asked. This will ensure that the .deb (and related metadata) is called (in my case)
bash_4.2-0ubuntu3patchCVE1_i386.deb
.Then you can try building with
dpkg-buildpackage -us -uc
ordebuild
command. Note - either of these will re-unpack the source from the zip - thus overriding any patches you may have had! Still, run one of these once so the source is unpacked and built (notedebuild
may still fail in the end due to texlive, but it should unpack and build the source).Then, apply the patches; note you should use
-p1
here, because currently you're in thebash-4.2/
directory:Then rebuild patched version by running:
This would rebuild the executable; to test it:
To build the .deb files, run:
This will save the .deb files in the parent directory; to list their contents:
To install the .deb:
However, for some reason, this .deb contains an unpatched binary (?!), so I had to additionally do:
... and after that, the test started passing correctly for me: