TL;DR
A Bash attack (specifically, Shellshock) exploited a vulnerability in older versions of the Bash shell. This guide helps you check if your system is vulnerable and how to mitigate it.
Checking for Vulnerability
- Identify Your Bash Version: The first step is to find out which version of Bash you’re running.
bash --versionThis command will output something like:
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) - Vulnerable Versions: Bash versions prior to 4.3.30 are generally considered vulnerable. Versions between 4.3 and 4.3.29 are also susceptible under certain conditions.
- Run a Vulnerability Test Script: Several scripts can test for the Shellshock vulnerability. Here’s how to use one:
- Download the test script (e.g., from GitHub).
- Make the script executable:
chmod +x shellshock.sh - Run the script:
./shellshock.sh - The script will report if your system is vulnerable and provide details.
- Alternative Test with `env` Variable: You can also try a simple test using the
envvariable:env X='() { :; }; echo vulnerable' bash -c 'echo "This is a test"'- If your system prints “vulnerable”, you are likely affected.
- If it just prints “This is a test”, you are probably safe.
Mitigation Steps
- Update Bash: The most effective solution is to update your Bash version to 4.3.30 or later.
- Debian/Ubuntu:
sudo apt-get updatesudo apt-get upgrade bash - CentOS/RHEL/Fedora:
sudo yum update bash - macOS (using Homebrew):
brew updatebrew upgrade bash
- Debian/Ubuntu:
- Apply Patches: If updating isn’t immediately possible, some distributions provide temporary patches. Check your distribution’s security advisories.
- Disable Affected Services (Temporary): As a short-term measure, you can disable services that use Bash to execute CGI scripts or other potentially vulnerable code. This is not a long-term solution but can reduce immediate risk.
- Web Server Configuration: If the vulnerability is exposed through your web server:
- Apache: Configure Apache to not pass environment variables to CGI scripts.
- Nginx: Similar configuration options are available in Nginx.
Further Information
For more detailed information, refer to these resources: