Disassembling an attempted Shellshock exploit
The Shellshock vulnerability in bash allowed attackers to execute arbitrary commands by sending crafted HTTP headers to CGI scripts. The report analyses an observed exploit that downloaded and executed a malicious binary, which would connect back to the attacker.
iinteractive.com
Published on iinteractive.com
technology , security , shellshock
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 evaluated the entire contents of environment variables that looked like function definitions, instead of stopping at the closing brace, allowing command injection.
Impact
If outbound HTTP traffic is allowed, the attack could download and execute a binary that spawns a shell and connects back to the attacker, leading to remote control; a firewall blocking outbound traffic would prevent this specific attack.
What the attacker needed
Vulnerable bash version; CGI script using bash; outbound HTTP allowed
The fix
Systems should be updated to a patched version of bash that does not evaluate trailing commands in function definitions.
How it was found
- Attacker sends an HTTP request with a crafted Cookie header containing a bash function definition followed by shell commands.
- The vulnerable CGI script spawns a bash subshell, which evaluates the header value and executes the commands.
- The commands download a binary from a remote server using wget, lwp-download, or curl.
- The binary is made executable and run, connecting back to the attacker.
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.
A bug in the bash shell meant that certain environment variables could contain commands that bash would run. When a web server passed user-controlled headers to a CGI script, an attacker could sneak in commands. This report looks at one real attack that used this to download and run a malicious program.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.