Shellshock is the name given to a family of remote code execution flaws in GNU Bash, disclosed in September 2014, in which the shell executed commands that followed a function definition stored in an environment variable. Among the best-known vulnerabilities in cybersecurity, it is tracked primarily as CVE-2014-6271, with follow-up identifiers CVE-2014-7169, CVE-2014-7186, CVE-2014-7187, CVE-2014-6277 and CVE-2014-6278.
The flaw had existed in Bash for roughly 25 years before discovery, and it became dangerous because many network services passed attacker-controlled input into environment variables before invoking a shell. Its maximum CVSS base score of 10.0 reflected trivial exploitation, no authentication and complete system compromise.
How Shellshock abuses Bash function export
Shellshock arises from the way Bash exports shell functions to child processes. Bash allowed a function to be passed to a subshell by placing its body in an environment variable whose value began with the characters () {, and the child Bash process parsed every such variable at startup to recreate the function.
The parser did not stop at the closing brace of the function. Any trailing commands after the definition were executed immediately while the new shell initialized, before any script logic ran. A variable such as X='() { :; }; /bin/id' therefore caused the command /bin/id to run in every Bash process that inherited it.
The essential precondition is a trust boundary crossing: a remote party controls the value of an environment variable, and some component later starts Bash with that environment. The variable name is irrelevant, which is why HTTP headers, DHCP options and SSH parameters all became viable injection channels.
The following table summarizes the stages of a typical exploitation chain.
| Stage | What happens | Example |
|---|---|---|
| Input capture | A service receives attacker-supplied data | HTTP User-Agent header |
| Environment mapping | The data is copied into an environment variable | CGI sets HTTP_USER_AGENT |
| Shell invocation | A Bash process starts with that environment | CGI script or system() call |
| Function import | Bash parses the () { prefix as a function | Definition is recreated |
| Trailing execution | Commands after the definition run | Reverse shell or downloader |
The CVE identifiers in the Shellshock family
Shellshock is not one bug but a cluster of related parser flaws. The first patch for CVE-2014-6271 was incomplete, and researchers quickly found further ways to reach dangerous behavior in the same function-import code, which produced several additional CVE entries within days.
The table lists the main identifiers and their nature. Severity scores were revised over time, so the values describe the general class rather than a fixed rating.
| Identifier | Nature of the flaw | Impact class |
|---|---|---|
| CVE-2014-6271 | Commands after a function definition are executed | Remote code execution |
| CVE-2014-7169 | Incomplete fix allowed file writes and command runs | Remote code execution |
| CVE-2014-7186 | Out-of-bounds access with nested here-documents | Crash, possible corruption |
| CVE-2014-7187 | Off-by-one error in nested loop parsing | Crash, possible corruption |
| CVE-2014-6277 | Uninitialized memory use in function parsing | Potential code execution |
| CVE-2014-6278 | Parser accepted further crafted definitions | Remote code execution |
The durable fix changed the design rather than the parser alone. Patched Bash versions only import functions from variables with a distinctive name prefix and suffix, such as BASH_FUNC_name%%, so arbitrary variables such as HTTP headers can no longer be interpreted as function definitions.
Attack vectors and exposed systems
Exposure depended on whether a reachable service passed remote data into a Bash environment. A vulnerable Bash binary alone was not remotely exploitable; the risk came from the surrounding software and its configuration.
The most exploited vector was CGI on web servers, because the CGI specification maps request headers directly into environment variables. Embedded devices were heavily affected as well, since many routers, network-attached storage units and industrial controllers used shell-based CGI scripts and were rarely patched.
| Vector | Precondition | Typical exposure |
|---|---|---|
| Web CGI scripts | Script or helper runs under Bash | High, widely scanned |
| DHCP clients | Client hook scripts use Bash | Local network attacker |
| OpenSSH forced commands | ForceCommand with Bash as login shell | Authenticated users only |
| Mail servers | Delivery filters invoke Bash with header data | Configuration dependent |
| Embedded web panels | Firmware uses Bash for CGI | High, slow patching |
Attackers began mass internet scanning within hours of disclosure. Payloads ranged from simple probes that requested a callback to droppers that installed botnet malware for DDoS attacks and cryptocurrency mining.
Shellshock compared with other landmark vulnerabilities
Shellshock is often discussed alongside Heartbleed and Log4Shell because all three affected ubiquitous components that defenders did not inventory well. Their mechanisms and consequences differ significantly.
| Vulnerability | Component | Weakness type | Primary impact |
|---|---|---|---|
| Shellshock | GNU Bash | Command injection via parser | Remote code execution |
| Heartbleed | OpenSSL | Missing bounds check | Memory disclosure |
| Log4Shell | Apache Log4j | Unsafe lookup and JNDI loading | Remote code execution |
| EternalBlue | Windows SMBv1 | Buffer overflow | Remote code execution, worms |
In CWE terms, Shellshock is usually mapped to CWE-78, OS command injection, because data crosses into command execution without neutralization. Unlike a memory-safety bug such as a buffer overflow, it requires no exploit engineering, which explains its rapid weaponization.
Detection, remediation and lasting lessons
The primary remediation is to upgrade Bash to a patched release supplied by the operating system vendor. A widely used local test sets a crafted variable and starts Bash: env x='() { :;}; echo vulnerable' bash -c 'echo test' prints the word vulnerable only on an unpatched shell.
- Inventory every Bash instance, including firmware, containers and appliance images, not only general-purpose servers.
- Remove or disable unused CGI scripts and avoid
/bin/shlinks to Bash where a minimal shell such as dash is sufficient. - Deploy web application firewall rules that block the
() {pattern as a temporary compensating control, not a fix. - Review logs for probe signatures in headers such as
User-Agent,RefererandCookieto identify past compromise.
A common mistake was treating the first patch as final. Teams that stopped after CVE-2014-6271 remained exposed to the follow-up identifiers, which shows why vulnerability management must track advisories until vendors declare the issue closed. Shellshock still appears in scans of neglected embedded devices, making it a frequent example of a long-lived N-day vulnerability.
Put simply
Bash is a program that reads and carries out text commands on many Linux and Unix computers. Shellshock was a mistake in how Bash read certain settings handed to it when it started. If someone hid an extra command at the end of one of those settings, Bash simply ran it.
Many websites and devices copied visitor details, such as the browser name, into those settings. An attacker could therefore send a single web request and take control of the machine. The fix was to update Bash so that it no longer trusts such settings.
In practice
A regional internet provider ran an older monitoring portal on a Linux server, and the portal used a Bash-based CGI script to display network status. Two days after the September 2014 disclosure, the security team saw web log entries with User-Agent values beginning with () { :; }; followed by wget commands that tried to download a botnet client.
The team confirmed the server was vulnerable with the standard env test, then blocked the pattern at the reverse proxy while the operating system package was updated. Because the first update covered only CVE-2014-6271, they repeated the upgrade when fixes for CVE-2014-7169 and later identifiers appeared. A file integrity review found no successful compromise, and the provider then retired the CGI portal and audited 40 customer routers that shipped with the same shell.