Bash susceptible to environment variables code injection attack

A security adversary posted at Red Hat’s security blog and referenced at US-CERT has warned users of the Bash shell of a “specially-crafted environment variables code injection attack.”

That means UNIX-based operating systems that use the Bash shell are affected. That includes all Linux distributions and Apple’s Mac OS X.

According to the blog post cited above:

… the vulnerability arises from the fact that you can create environment variables with specially-crafted values before calling the bash shell. These variables can contain code, which gets executed as soon as the shell is invoked. The name of these crafted variables does not matter, only their contents.

The flaw is said to have been fixed in Red Hat Enterprise Linux and a package that fixes it shipped for Fedora, but I am running a fully updated Fedora 20 KDE and the package has not comes across. To test whether your copy of Bash is vulnerable, issue this command: env x='() { :;}; echo vulnerable' bash -c "echo LinuxBSDos.com. If your Bash is vulnerable, you should see both echoed texts.

Related Post:  Deploying Machine Learning workloads in Kubernetes clusters that support GPUs

This screenshot shows the result of the test on my Fedora 20 desktop.
Bash code injection attack

On my laptop running Linux Mint 17 Cinnamon, the test showed that it, too, is vulnerable. However, after updating it, the test passed. The following screenshots shows the results of the test before and after the updated was applied.

Bash test on Linux Mint 17 before code injection attack update.
Bash bug Linux Mint

Bash test on Linux Mint 17 after updating the system.
patched Bash bug Linux Mint

UPDATE: If you use Fedora 20, your only option, before an update is pushed through the system, is to patch it manually. To do that, type the following command, as root: yum localinstall https://kojipkgs.fedoraproject.org//packages/bash/4.2.47/4.fc20/x86_64/bash-4.2.47-4.fc20.x86_64.rpm. That came from this post. For other editions of Fedora, see this other post.

Please share:

We Recommend These Services

Register now for Big Data & AI Conference, international Big Data and AI conference in Dallas, TX (USA), June 27 - 29, 2019

Reasons to use control panel for your server

Register for the End-to-end Machine Learning with TensorFlow on Google Cloud Platform workshop. It will be conducted by the manager of Google's Cloud AI Advocacy team

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).


  1. The article says, “That includes all Linux distributions…” It would be more accurate to say, “most Linux distributions,” or better yet, “virtually all Linux desktops and servers.” Most versions of embedded Linux don’t include bash and are not vulnerable. However, most distributions for customizable semi-embedded devices like the Raspberry Pi are/were vulnerable.

    • Yep, Red Hat has addressed that point in this update. Relevant paragraph:

      Only if your lightbulb runs Bash! Lots of press have latched onto the fact that this flaw could affect the Internet Of Things, allowing attackers to take control of your systems via home appliances. In reality, embedded devices rarely use Bash, going for more lightweight solutions such as BusyBox, which includes the ash shell that was not vulnerable to these issues. So while it’s certainly plausible that some devices may be affected by this flaw, it won’t be very common.

  2. it’s the final ” that is missed in your example…

    env x='() { :;}; echo vulnerable’ bash -c “echo LinuxBSDos.com

  3. on the last point of your command text, there is no this one “

  4. thxs for your contribution, but in your command text is on the end a fail:

    Must be:

    env x='() { :;}; echo vulnerable’ bash -c “echo LinuxBSDos.com”

    Greetings TLW

Leave a Comment

Your email address will not be published. Required fields are marked *