How to Protect Ubuntu Server Against the Shellshock Bash Vulnerability

Sponsored Link
On September 24, 2014, a GNU Bash vulnerability, referred to as Shellshock or the "Bash Bug", was disclosed. In short, the vulnerability allows remote attackers to execute arbitrary code given certain conditions, by passing strings of code following environment variable assignments.

The Shellshock vulnerability can be exploited on systems that are running Services or applications that allow unauthorized remote users to assign Bash environment variables. Examples of exploitable systems include the following:

  • Apache HTTP Servers that use CGI scripts (via mod_cgi and mod_cgid) that are written in Bash or launch to Bash subshells
  • Certain DHCP clients
  • OpenSSH servers that use the ForceCommand capability
  • Various network-exposed services that use Bash

Check System Vulnerability

On each of your systems that run Bash, you may check for Shellshock vulnerability by running the following command at the bash prompt:

env ‘VAR=() { :;}; echo Bash is vulnerable!‘ ‘FUNCTION()=() { :;}; echo Bash is vulnerable!‘ bash -c "echo Bash Test"

The highlighted echo Bash is vulnerable! portion of the command represents where a remote attacker could inject malicious code; arbitrary code following a function definition within an environment variable assignment. Therefore, if you see the following output, your version of Bash is vulnerable and should be updated:

Bash is vulnerable!
Bash Test

If your output does not include the simulated attacker's payload, i.e. "Bash is vulnerable" is not printed as output, you are protected against at least the first vulnerability. If there are any bash warnings or errors in the output, you should update Bash to its latest version.

If the only thing that is output from the test command is the following, your Bash is safe from Shellshock:

Bash Test

Fix Vulnerability: Update Bash

The easiest way to fix the vulnerability is to use your default package manager to update the version of Bash

For currently supported versions of Ubuntu or Debian, update Bash to the latest version available via apt-get:

sudo apt-get update

sudo apt-get install --only-upgrade bash

Now check your system vulnerability again by running the command in the previous section.

Via DigitalOcean

Sponsored Link

You may also like...

2 Responses

  1. Paul Austin says:

    You might want to consider turning off smart quotes as the text you have is wrong it has a smart quote instead of ‘

    env ‘VAR=() { :;}; echo Bash is vulnerable!’ ‘FUNCTION()=() { :;}; echo Bash is vulnerable!’ bash -c “echo Bash Test”

  2. Peter says:

    The check script is invalid due to smart quotes displayed.

Leave a Reply

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