Skip to content
RCE Write-up Beginner

ShElL sHoCk — Aren’t you also shocked ?

A web server running a CGI script on a vulnerable Bash version executes commands embedded in HTTP headers because Bash misinterprets function definitions in environment variables. An attacker could send a crafted header to run arbitrary commands and obtain a reverse shell.

Mr Jokar Follow

Published on systemweakness.com

Shell Shock is a shocking mistake that was lying under everyone’s nose for 25 years. It exploits a feature of Bash (≤ Version 4.3).

Mr Jokar, on systemweakness.com

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 versions up to 4.3 incorrectly parse function definitions in environment variables, treating trailing content after a function definition as commands to execute.

Impact

An attacker could execute arbitrary commands on the web server and obtain a reverse shell, giving full control of the server process.

What the attacker needed

Web server with CGI enabled; vulnerable Bash version (≤ 4.3); attacker can send HTTP requests

The fix

Upgrade Bash to a version that does not execute commands from environment variable function definitions.

How it was found

  1. Find a cgi-bin/ directory on the web server.
  2. Locate a CGI script such as a bash script in that directory.
  3. Capture a request to the script and modify a header such as User-Agent to include the magic syntax and a command.
  4. Send the request and observe command output to confirm the vulnerability.
  5. Replace the command with a reverse shell one-liner and start a listener.
  6. Send the request again to receive a shell on the 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 program that runs commands on Linux. Some web servers pass information from HTTP headers into Bash as environment variables. In old Bash versions, a specially crafted header could trick Bash into running extra commands, letting an attacker control 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.

More by Mr Jokar

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.