Apache Struts (S2-045)
CVE-2017-5638 let one unauthenticated request run commands on any server using a vulnerable Apache Struts. In 2017 attackers used it against an unpatched Equifax portal and stole data for 76 days.
- Affected
- Struts 2.3.5 to 2.3.31, 2.5 to 2.5.10
- Fixed in
- 2.3.32 and 2.5.10.1
- Published
- 2017-03-11
- Known exploited since
- 2021-11-03
What the flaw is
Struts 2 is a Java web framework. Its Jakarta file-upload parser mishandled a malformed upload header, and the attacker's header text was evaluated as an expression. One request was enough to run commands on the server, with no account.
Spot it in the logs
Which request started the program that sends records out?
Requests to upload endpoints, or any Struts action, with a strange Content-Type, Content-Disposition or Content-Length header. NVD notes the 2017 attacks used a Content-Type containing #cmd=.
How the attack works
- 1The attacker sends an upload request with an expression in Content-Type
- 2Struts' Jakarta parser evaluates the header
- 3The server runs the attacker's command, no account needed
- 4A web shell reads the database and sends records out
Why CVE-2017-5638 in Apache Struts was so severe
NVD scores CVE-2017-5638 9.8 out of 10 under CVSS 3.1, and 10.0 under the older CVSS 2 scale. CVSS is the common 0 to 10 scale for how dangerous a flaw is. The vector explains the score: the attack works over the network, is simple, needs no account and no user action, and gives high impact on confidentiality, integrity and availability. In practice, anyone who could reach a vulnerable Struts page could run commands on the server with the rights of the web application.
The root cause was in how Struts built an error message. When the Jakarta upload parser rejected a bad Content-Type header, it put the header text into the error message, and Struts evaluated that message as an OGNL expression. OGNL (Object Graph Navigation Language) is the expression language Struts uses for most of its processing. Trend Micro notes that OGNL is behind most Struts remote code execution flaws, because it makes running arbitrary code easy.
GAO describes Struts as a commonly used open source framework for building web applications, so the flaw sat behind many public sites. CISA later listed CVE-2017-5638 among the top 10 vulnerabilities most exploited by state and criminal actors from 2016 to 2019. It is also the flaw behind the 2017 Equifax breach.
Is your version affected?
- Linux and macOS
find / -name 'struts2-core-*.jar' 2>/dev/null - Maven project
mvn dependency:tree -Dincludes=org.apache.struts
Affected. Upgrade to 2.3.32 / 2.5.10.1.
How to detect the Apache Struts flaw
Find every Struts application first, because Equifax's own scan missed one, then check traffic, processes and files on each.
- Inventory every Struts applicationSearch servers for struts2-core JAR files and record their versions; 2.3.5 to 2.3.31 and 2.5 to 2.5.10 are vulnerable. Do not rely on one network scan: GAO reports that Equifax scanned its network a week after the alert and the scan did not find the flaw on the dispute portal. Check whether each application uses the Jakarta multipart parser, the upload parser named in the advisory.
- Inspect upload headers in web logsA normal file upload has a Content-Type that starts with multipart/form-data. Look for requests whose Content-Type, Content-Disposition or Content-Length holds an expression instead, such as text with %{ or #cmd=, which NVD notes was used in the 2017 attacks. S2-046 shows that the other two headers can carry the attack too, so log all three.
- Turn on intrusion detection rulesNetwork sensors had signatures within days. Talos released Snort rules 41818 and 41819 on 7 March 2017, and Trend Micro published rules such as Deep Security 1008207. Make sure these or newer equivalents are enabled, and alert on hits followed by unusual server activity rather than on the hits alone.
- Watch for commands started by JavaA Java application server such as Tomcat should rarely start a shell. Alert when it runs commands like whoami, ifconfig or id, stops the firewall service, or downloads and runs files, the steps Talos saw in the first attacks. Check boot scripts and services for new entries that start downloaded programs.
- Hunt for web shellsLook for new or changed JSP files and other pages in the application's web folders that are not part of a release. Equifax's attackers left about 30 web shells. Compare deployed files with the release package or a known good copy.
- Make sure encrypted traffic is inspectedEquifax had a tool to inspect outbound traffic, but an expired certificate stopped it working, so data left over encrypted connections unseen. Track expiry dates for certificates on monitoring devices. Also alert when a web application account runs far more database queries than normal, as Equifax's attackers did.
Check a log line
Search the logs yourself
Which request ran code on the disputes server? Look at the Content-Type headers.
Fix it, in this order
- 1Upgrade StrutsInstall 2.3.32 or 2.5.10.1. A header filter is not a fix: the flaw has more than one door.
- 2Stop the leakStop the program sending data and block the server's outbound traffic it does not need.
- 3Remove the web shellFind files added among the application's pages and quarantine them.
Related vulnerabilities
Timeline
- 2017-03-08US-CERT warns about the flaw
- 2017-03-10Attackers scan Equifax for it and find an unpatched portal
- 2017-05-13Data theft begins, in small pieces over encrypted connections
- 2017-07-29Equifax notices after 76 days, when an expired certificate is renewed
Apache Struts attacks in the wild
Mass attacks started the day the proof of concept appeared. Cisco Talos saw a high volume of attempts, mostly copies of the public code. Attackers first ran whoami and ifconfig to learn the server's user and network, then stopped Linux firewalls, downloaded payloads and set them to run at boot. Payloads included an IRC bouncer, a DoS bot and malware linked to the Bill Gates botnet. Imperva counted several thousand attacks from 1,323 IP addresses in 30 countries between 7 and 12 March 2017.
Governments were hit within days. Attackers exploited the flaw against a Statistics Canada server on 9 March, and officials said no data was stolen. As a precaution, the Canada Revenue Agency took its tax filing site offline on 10 March, and services were back on 12 March.
At Equifax, attackers scanned for the flaw on 10 March, two days after the US-CERT alert, and found the unpatched online dispute portal. From 13 May they returned, installed about 30 web shells (hidden pages that let attackers run commands, per the House Oversight Committee), and found unencrypted usernames and passwords. These let them move from the portal's 3 databases to 48 others and run about 9,000 queries, sending data out in small encrypted pieces. In February 2020 the US Justice Department charged four members of China's People's Liberation Army 54th Research Institute with the hack, saying they routed traffic through about 34 servers in 20 countries. Data on about 145 million Americans was taken; the UK fined Equifax £500,000.
Who found the Apache Struts flaw
Nike Zheng reported the flaw to the Apache Struts project, which published advisory S2-045 in early March 2017 and released Struts 2.3.32 and 2.5.10.1 as fixes. Talos dates the advisory to 6 March and says a public proof of concept appeared in the early afternoon of 7 March. Rapid7 also saw the first exploit attempts on 7 March. US-CERT warned about the flaw on 8 March, and NVD published the CVE on 11 March. Apache rated it Critical.
A few days later Apache published S2-046, crediting Chris Frohoff, Nike Zheng and Alvaro Munoz. It described a different way into the same bug, through a malicious Content-Disposition value or a bad Content-Length header, and shares the same CVE id. That is why a filter on the Content-Type header alone was never a full fix.
Lessons from the Apache Struts breach
The Equifax breach became the standard example of what happens when a patch exists but does not reach the right system. GAO reports four factors that Equifax itself identified: identification, detection, segmentation and data governance. The alert went to an out of date email list, so the people who owned the portal never saw it. A scan missed the flaw. An expired certificate blinded the traffic monitor. Weak segmentation let attackers move from one portal to dozens of databases, and stored passwords were not encrypted. Sources differ on how long that certificate had expired: GAO says about 10 months, the House Oversight Committee says 19 months.
The lesson for teams today is to know every application and its framework version, to have a patch process with owners for each system, and to plan migrations off old framework lines. Struts 2.3 reached end of life in 2019 and 2.5 in October 2023, and Apache gives no support at all to end-of-life versions. Even so, Sonatype found in January 2026 that most Struts downloads from Maven Central in one week were versions from these two unsupported lines.
The case
Struts: The Disputes Portal
- Find what the advisory affects
- How did they get in?
- Stop the leak, close the hole
- Remove the web shell
Questions
How many people did the Equifax breach affect?
The GAO puts it at about 145.5 million people; the FTC's settlement says 147 million.
Was a patch available before the Equifax breach?
Yes. Apache fixed the flaw in March 2017; the breach started in May on a portal that had not been patched.
What is CVE-2017-5638?
CVE-2017-5638 is a remote code execution flaw in the Jakarta file upload parser of Apache Struts 2, published in March 2017 as advisories S2-045 and S2-046. A crafted Content-Type, Content-Disposition or Content-Length header let an attacker run commands on the server without an account. It is the flaw used in the 2017 Equifax breach.
How do I fix CVE-2017-5638?
Upgrade Struts to 2.3.32 or 2.5.10.1 or, better, to a current supported release, since both of those lines are now end of life. Apache's advisory also listed temporary workarounds, such as a filter that drops requests whose Content-Type is not multipart/form-data, but they do not cover every vector. Then check the server for web shells and unknown programs.
Is the Apache Struts flaw still a threat?
Yes, for servers that were never updated. CISA added it to its Known Exploited Vulnerabilities catalog in November 2021 and listed it among the most exploited flaws of 2016 to 2019. Old, unsupported Struts versions are still widely downloaded, so unpatched copies remain in use.
How did hackers get into Equifax?
They exploited CVE-2017-5638 on Equifax's online dispute portal, which had not been patched. From there they found stored usernames and passwords, reached 48 more databases, and ran about 9,000 queries over 76 days. The US charged four Chinese military hackers in 2020.
What is Apache Struts used for?
Apache Struts 2 is an open source framework for building Java web applications, which GAO calls commonly used. It relies on an expression language called OGNL for most of its processing. Struts 7.4.0 is the current recommended release.
How much did the Equifax breach cost Equifax?
The FTC's settlement includes up to $425 million to help people affected by the breach. The UK's data protection regulator also fined Equifax £500,000, the maximum under the law in force before GDPR.