Shellshock
Shellshock was a bug in Bash, the shell on most Linux and Unix systems. Web servers that ran CGI scripts passed request headers to Bash, so one crafted header could run any command on the server.
- Affected
- Bash 1.14 to 4.3
- Fixed in
- Bash 4.3 patch 26 (patch 25 was incomplete)
- Published
- 2014-09-24
- Known exploited since
- 2022-01-28
What Shellshock is
Bash lets a program pass shell functions to the programs it starts, through environment variables. Vulnerable versions also ran any command written after the function definition.
A web server running a CGI script copies request headers like User-Agent into environment variables before starting Bash. An attacker who puts a function definition and a command in a header gets that command run on the server.
Spot it in the logs
Every request below reached a CGI script. Which one ran a command?
Look for header values that begin with a fake function definition, () {, most often in User-Agent but also in Cookie, Referer or Host. SANS recommends searching every header, since many are not logged by default.
A request that worked is usually followed by the server downloading something or connecting out to the attacker, then a new program running from /tmp or /var/tmp.
How the attack works
- 1The attacker puts () { :;}; and a command in a header
- 2The web server hands the header to a CGI script
- 3Bash defines the function and also runs the command
- 4The command downloads a bot from the attacker
Why Shellshock was so severe
NVD scores Shellshock 9.8 out of 10 under CVSS 3.1 and 10.0, the maximum, under the older CVSS 2. The vector explains why: it is reachable over the network, needs no login and no action from a user, and gives full control of what the vulnerable program can do. CISA rated its access complexity as low, meaning little skill is needed to exploit it.
Bash was everywhere. It was the default shell on Linux and Mac OS X, and on many systems /bin/sh itself was Bash. The flaw was also old: the Bash maintainer traced the function import feature, and the bug with it, back to August 1989 and Bash 1.03. So almost every Bash release ever shipped had it.
The hard part for defenders was that Bash is rarely the program facing the network. It is started by other programs, and any of them that copies outside data into an environment variable becomes a door. NVD and Red Hat list Apache CGI scripts (mod_cgi and mod_cgid), the OpenSSH ForceCommand feature, DHCP clients that run scripts, and CUPS printing filters. Finding every path on every machine, including routers and storage boxes with Bash built into their firmware, took far longer than installing one patch.
Is your version affected?
- Linux and macOS
bash --version - Test your own Bash
env x='() { :;}; echo vulnerable' bash -c 'echo test'
Affected. Upgrade to 4.3.26.
How to detect Shellshock
Shellshock leaves traces in web logs, in process trees and in outbound traffic, so check all three.
- Search request logs for the function prefixLook for the characters () { at the start of any header value or request parameter. The most common published form is () { :;}; followed by a command. SANS saw it in User-Agent, Cookie, Host and Referer, and Cloudflare also saw it in GET and POST arguments. Default access logs record only some headers, so a WAF or proxy log is often the better place to search.
- Look for download commands inside headersPayloads usually call wget, curl, lwp-download or perl, or open a connection with /dev/tcp/. A header that contains any of these words is an attack even if it failed. Match the time of each hit against the web server's outbound connections to see if one worked.
- Watch what the web server startsA CGI script normally starts a short, predictable set of programs. An httpd or www-data process that starts bash, then wget, curl or perl, is a strong sign. Process auditing on Linux, or an EDR tool, records these parent and child relationships.
- Check temporary folders and startup filesSANS found dropped files such as /tmp/cgi, /tmp/xrt, /var/tmp/ec.z and /var/tmp/wow1, and Cloudflare saw a Python script disguised as a ClamAV update. On QNAP devices, look for an SSH server on port 26, an unknown admin user, extra CGI files and changes to autorun.sh. Treat any executable in /tmp or /var/tmp that nobody installed as suspect.
- Watch outbound traffic from serversMany Shellshock bots connected out to IRC servers, on ports such as 6667 and 7777 in the SANS samples, or opened reverse shells. A web server rarely needs to start connections to the internet, so egress firewall logs make these easy to spot.
- Test the Bash version itselfRed Hat published a local one-line test: it sets an environment variable holding a function definition followed by an echo, then starts Bash. If the word vulnerable is printed, Bash is unpatched. A network scanner with a Shellshock check helps for devices where you cannot log in.
Check a log line
Search the logs yourself
Which request made the menu server run a program? Search the log.
Fix it, in this order
- 1Update BashInstall the latest Bash your system offers. The first patch was incomplete.
- 2Find what got inLook for downloads or connections right after a request with () { in a header.
- 3Remove the botStop it, remove its startup entry and quarantine its file in /tmp or /var/tmp.
Related vulnerabilities
Timeline
- 2014-09-24Shellshock is disclosed
- 2014-09SANS honeypots record mass scanning and bot installs within days
- 2022-01-28CISA adds it to its catalog of exploited vulnerabilities
Shellshock attacks in the wild
Scanning started almost at once. On 29 September 2014 the SANS Internet Storm Center published the payloads its honeypots had collected: simple checks that printed a marker word, requests that ran uname or read /etc/passwd, and droppers that downloaded a Perl script to /tmp, ran it and deleted it. Many of those scripts joined an IRC channel to receive commands, which made the server part of a botnet. Cloudflare reported on 30 September that it had already blocked well over 1.1 million Shellshock attempts, at 10 to 15 per second in the first hours. About 83% were reconnaissance and about 8% tried to take control of the server.
Within days, malware families were built around it. Trend Micro received the first samples of the BASHLITE backdoor on 4 October 2014, listing Shellshock as the way it arrived. BASHLITE runs flooding (DDoS) attacks on command and tries common default passwords to spread. On 14 December 2014 SANS described a worm that broke into QNAP network storage devices through the CGI script /cgi-bin/authLogin.cgi, which needs no login. It added an SSH server on port 26 and an admin user named "request", ran click fraud against an ad network, scanned for more victims and then installed QNAP's patch itself to keep other attackers out.
The attacks never fully stopped, because many embedded devices were never updated. CISA added CVE-2014-6271 and CVE-2014-7169 to its Known Exploited Vulnerabilities catalog on 28 January 2022, and added the follow-up flaw CVE-2014-6278 on 2 October 2025, eleven years after disclosure.
Who found Shellshock
Stéphane Chazelas found the bug and reported it privately to Bash maintainer Chet Ramey on 12 September 2014. He called it "Bashdoor". Florian Weimer announced it on the oss-security mailing list on 24 September 2014, credited Chazelas, and noted that it was exploitable over the network in many common setups. It became known as Shellshock.
The first patch was not enough. On the day of disclosure, Tavis Ormandy showed a way around it, which became CVE-2014-7169. Michał Zalewski then found two more parser flaws (CVE-2014-6277 and CVE-2014-6278), and Florian Weimer and Todd Sabin found two memory bugs (CVE-2014-7186 and CVE-2014-7187). Bash 4.3 patches 25, 26 and 27 were out by 25 September, and vendors also changed how Bash imports functions so that ordinary variables no longer reach the function parser.
Lessons from Shellshock
Shellshock showed that a component nobody thinks of as internet facing can still be reached from the internet, through a chain of programs that pass data along. CGI scripts that hand request data to a shell were already old technology in 2014, and many survived only on forgotten admin pages and device firmware. Retiring legacy interfaces, and knowing which software is inside each appliance, matters as much as patching servers.
It also showed the cost of a rushed, partial fix. Six CVEs and three patches followed within about a week, and the real fix was a design change: Red Hat explains that patched Bash only imports functions from variables named BASH_FUNC_name(), so ordinary values such as a User-Agent are never parsed as code. Finally, egress filtering paid off: payloads that depended on wget or curl failed on servers that could not connect out, even before Bash was patched.
The case
Shellshock: The Menu Server
- Find what the advisory affects
- Were we hit?
- Close it without taking the menu offline
- Remove the bot
Questions
Does Shellshock still matter?
Yes, on old embedded devices and forgotten servers that still run CGI scripts with an unpatched Bash. CISA added it to its exploited vulnerabilities catalog in 2022.
Is removing the bot enough?
No. While the hole is open the next request installs it again. Patch Bash first, then remove what the attackers left.
What is Shellshock?
Shellshock is a family of bugs in GNU Bash, disclosed on 24 September 2014, with CVE-2014-6271 as the first. Bash ran commands that were placed after a function definition in an environment variable. Any program that copied outside input into an environment variable and then started Bash, such as a CGI web script, could be used to run commands.
Has Shellshock been patched?
Yes. Bash was fixed within days, through Bash 4.3 patches 25 to 27, and operating system vendors shipped updated packages, such as Red Hat's fixed bash builds. The first patch was incomplete, so only the later updates fix the whole family. Devices whose firmware was never updated stay vulnerable.
How do I check if I am vulnerable to Shellshock?
On a machine you control, update Bash and run your vendor's test, such as the one Red Hat published, which prints the word vulnerable on an unpatched Bash. For appliances and network devices, check the vendor's advisory and firmware version, or use a vulnerability scanner with a Shellshock check.
How do I fix Shellshock?
Install the latest Bash package from your operating system, and update the firmware of routers, storage devices and other appliances. Then look for signs that an attacker already got in, because the patch does not remove a bot that is running. Where possible, turn off old CGI scripts and block outbound connections from servers that do not need them.
Does Shellshock affect Macs?
Yes, in 2014 it did. CISA listed Mac OS X among the systems with Bash in the base system, so Macs of that time needed the Bash update. A Mac was exposed only through a program that passed outside data to Bash, such as a web server running CGI scripts.
Why is it called Shellshock?
Bash is a shell, the program that reads and runs commands, and the bug let attackers send it commands from outside. Its finder, Stéphane Chazelas, had called it Bashdoor.