Shellshock — A deep dive into CVE-2014–6271
A flaw in Bash's parsing of function definitions in environment variables allowed an attacker to execute arbitrary commands when a CGI script invoked Bash. An attacker could send a crafted HTTP header to a vulnerable Apache server running CGI scripts and gain remote code execution.
Shellshock is a critical vulnerability discovered in 2014 affecting the GNU/Bash shell. It allowed attackers to execute code remotely on the vulnerable Apache web server.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Bash incorrectly parsed function definitions in environment variables, executing trailing commands after the function body.
Impact
An attacker could execute arbitrary commands on the vulnerable server, potentially gaining full control.
What the attacker needed
Apache with CGI scripts invoking Bash; Bash version ≤ 4.2; Network access to the server
The fix
The vulnerability should be fixed by patching Bash to correctly handle function definitions in environment variables, and by avoiding passing untrusted input to Bash.
How it was found
- Fill out a form on the vulnerable site and capture the request.
- Use an nmap script called 'http-shellshock' to check for vulnerability.
- Send a basic payload to test if the site is vulnerable.
- Remove the 'Accept-Encoding' header to decode the response.
- Use curl to send the payload.
- Attempt to get a reverse shell on the web server.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Bash is a common command-line shell on Linux. When a web server runs a CGI script, it passes request details like the User-Agent header as environment variables. Bash had a bug where it would treat part of such a variable as a function definition and then run any commands that followed, letting an attacker run their own commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.