Menu

Log4Shell

CVE-2021-44228Critical · 10.0

Log4Shell let anyone who could get a line of text into a Java application's logs make the server fetch and run their code. It was exploited at mass scale from December 2021 and is still scanned for today.

Affected
Log4j 2.0-beta9 to 2.14.1
Fixed in
2.15.0, then 2.17.1 for the follow-up flaws
Published
2021-12-10
Known exploited since
2021-12-10

What Log4Shell is

Log4j is the logging library inside a huge number of Java applications. Vulnerable versions treat some text inside a logged message as an instruction: a JNDI lookup that fetches something over the network.

If an attacker gets their text into anything the application logs (a login name, a header, a search box), the server reaches out to a server the attacker controls and can load and run code from it. No password is needed.

Spot it in the logs

Scanners tried this all morning. Which request got in?

The attack string starts with ${jndi: followed by a protocol such as ldap, rmi or dns and the attacker's address. It can sit in any logged field, and attackers disguise it with nested lookups, so matching one exact string is not enough.

The surest sign is what the server does next: an outbound connection from the Java server to an unknown address, usually over LDAP, right after the string was logged. Scanners that found nothing leave the string but no callback.

How the attack works

  1. 1The attacker puts a ${jndi:ldap://...} string in a header or a login name
  2. 2The app logs it, and Log4j runs the lookup inside it
  3. 3The server connects to the attacker's LDAP server
  4. 4It loads and runs the attacker's code

Why Log4Shell was so severe

NVD scored Log4Shell 10.0, the highest CVSS score possible. The US Cyber Safety Review Board explains why: the attack needed low complexity, no account and no action from a user. CVSS is the common 0 to 10 scale for how dangerous a flaw is. The score also marks the flaw as "scope changed": code run through the logging library could reach far beyond the library itself.

The bigger problem was reach. Log4j had been a popular Java building block since 1999. Between August and November 2021 it was downloaded 28.6 million times, and by 14 December 2021 almost 7,000 open source projects used it as a dependency. CISA and its partner agencies pointed out that it sat inside consumer and enterprise services, websites, applications and industrial (OT) products. Many teams did not know they had it, because it came bundled inside other software. The Board found that system owners often could not tell where the vulnerable code lived.

Finding and fixing every copy took months. The Board reported that one US federal cabinet department spent 33,000 hours on its Log4j response. It concluded that Log4j is an "endemic" vulnerability: vulnerable copies will stay in systems for many years, perhaps a decade or longer.

Is your version affected?

  • Linux and macOSfind / -name 'log4j-core-*.jar' 2>/dev/null
  • Windows (PowerShell)Get-ChildItem C:\ -Recurse -Filter 'log4j-core-*.jar' -ErrorAction SilentlyContinue
  • Maven projectmvn dependency:tree -Dincludes=org.apache.logging.log4j
  • Gradle projectgradle dependencies | grep log4j

Affected. Upgrade to 2.17.1.

How to detect Log4Shell

Start by finding every copy of Log4j, then look for attempts in your logs and for what the server did after them.

  • Find every log4j-core fileSearch servers, containers and installed products for log4j-core JAR files, including copies nested inside WAR, EAR and other JAR files. Compare their versions with the fixed releases on Apache's security page, which lists separate releases for Java 6, Java 7 and Java 8 or later. CISA's advisory lists free scanners, such as CERT/CC's CVE-2021-44228_scanner, and lists of file hashes for vulnerable JARs. Ask vendors about products you cannot open.
  • Search logs for the lookup stringSearch web, application and proxy logs for ${jndi: followed by ldap, ldaps, rmi, dns, iiop or http, in every field: User-Agent, headers, usernames, form fields. Also search for disguised forms Cloudflare published, such as ${lower:, ${::-j}, ${env:NOTEXIST:-h} and URL-encoded %24%7B. A hit only proves someone tried; many hits are harmless scanners.
  • Watch for the callbackA successful attack makes the Java server connect out to the attacker. Look in firewall, DNS and proxy logs for outbound LDAP, RMI or DNS traffic from Java servers to unknown addresses, especially seconds after a logged lookup string. Microsoft's hunting guidance flags new external LDAP servers. Testing services such as interact.sh, canarytokens.org and dnslog.cn also show up and may be legitimate scans, so confirm them.
  • Look at what Java startedCheck endpoint logs for java or javaw processes starting shells, PowerShell, curl or wget, or Base64-encoded commands. On VMware Horizon, Microsoft points to child processes of ws_TomcatService.exe. Coin miners, reverse shells and Cobalt Strike beacons were the most common follow-ups.
  • Hunt for persistenceAttackers often stayed after the fix. In the federal agency case, CISA lists signs to check: a Windows Defender exclusion for the whole C: drive, XMRig files such as WinRing0x64.sys and wuacltservice.exe, a scheduled task named RuntimeBrokerService.exe, and HTTPS traffic to ngrok domains. It also advises watching for account creation and changes (Windows event IDs 4728, 4738 and 4670) and RDP logons (event ID 4624, logon type 10).
  • Use detection rules and review changesLoad published Sigma, YARA and Emerging Threats rules for Log4j into your monitoring tools; CISA's advisory links them. CISA also advises reviewing configuration changes made since 1 December 2021, because some attackers patched the hole themselves to keep others out.

Check a log line

Search the logs yourself

Find the request that made the server call out. Search the log with grep, for example for jndi.

rewards: /var/log/events.log

Fix it, in this order

  1. 1Upgrade Log4jInstall the newest release for your Java version. 2.15.0 was incomplete, so go past it.
  2. 2Until then, cut the callbackBlock outbound LDAP, RMI and DNS from the server, or remove the JndiLookup class. Both are temporary.
  3. 3Hunt what already ranLook for programs the attack started, such as coin miners, and remove them so they do not come back.
  • CVE-2021-45046The 2.15.0 fix was incomplete in some non-default setups that use Thread Context lookups, which could still leak data or run code. Apache scored it 9.0 and fixed it in 2.16.0 (2.12.3 for Java 7).
  • CVE-2021-45105A self-referencing lookup could make Log4j recurse until the process crashed, a denial of service scored 5.9. It was fixed in 2.17.0 (2.12.3 for Java 7).
  • CVE-2021-44832An attacker who can already change the logging configuration could run code through a JDBC Appender with a JNDI data source. Scored 6.6, it is listed as fixed in 2.17.1 in Apache's release notes, while Apache's security page names 2.17.0, so 2.17.1 or later is the safe target.
  • CVE-2021-4104Log4j 1.x has no lookups, so it is not hit by Log4Shell, but its JMSAppender can be abused when JNDI is set in the configuration. Log4j 1 has been end of life since 2015 and gets no fixes.

Timeline

  1. 2021-12-10The CVE is published, and CISA lists it as exploited the same day
  2. 2021-12Mass exploitation: coin miners, Cobalt Strike, ransomware (Microsoft)
  3. 2022-02Attackers break into a US federal agency through an unpatched VMware Horizon server (CISA)

Log4Shell attacks in the wild

Exploitation began before disclosure. The Board reports that a technology company saw the earliest known attempts over two days starting 1 December 2021, which looked like testing. Cloudflare logged its first attempt nine minutes after the public tweet on 9 December. On 10 December it was blocking about 20,000 exploit requests a minute at the peak, from 200 to 400 scanning addresses at a time. Many requests hid the string with nested lookups such as ${lower:l} to slip past filters.

Microsoft tracked a long list of attackers. Coin miners, the Mirai botnet and Cobalt Strike payloads were common. Khonsari ransomware hit modified Minecraft servers through chat messages. The Iranian group Microsoft calls PHOSPHORUS adapted the exploit, and the China-based ransomware operator DEV-0401 used it against internet-facing VMware Horizon servers to deploy NightSky ransomware from 4 January 2022. The Belgian Ministry of Defence detected an intrusion through Log4j on 16 December 2021 and said its activity was paralysed for several days.

State-backed groups kept using it long after the patch. Mandiant reported in March 2022 that APT41, a China-linked group, compromised at least six US state government networks between May 2021 and February 2022, partly through Log4j. CISA and the FBI found that likely Iranian government actors entered a US federal civilian agency in February 2022 through an unpatched VMware Horizon server, then ran the XMRig miner, Mimikatz and Ngrok tunnels. In November 2024 CISA still listed Log4Shell among the 15 most routinely exploited vulnerabilities of 2023.

Who found Log4Shell

Chen Zhaojun of the Alibaba Cloud Security Team found the flaw and reported it to the Apache Software Foundation by email on 24 November 2021, with a proof of concept. The risky feature, JNDI lookup support, had been added to Log4j in July 2013 and shipped in version 2.0-beta9. JNDI (Java Naming and Directory Interface) is a Java feature that looks up objects in directory services such as LDAP. Apache worked on a fix in public pull requests from 29 November and tagged a release candidate of 2.15.0 on 6 December, without an advisory yet.

On 9 December the Alibaba engineer told Apache the bug was being discussed on WeChat, where a Chinese security company had posted a redacted screenshot of a working exploit. The same day a tweet disclosed the flaw with a proof of concept on GitHub, and the LunaSec team named it Log4Shell. Apache moved the release forward and published 2.15.0 and CVE-2021-44228 on 10 December. Fixes for follow-up flaws came on 13 December (2.16.0), 17 December (2.17.0) and 27 December (2.17.1). Alibaba informed China's industry ministry on 13 December, which the Board noted was 17 days after a Chinese reporting deadline.

Lessons from Log4Shell

The first lesson was inventory. The Cyber Safety Review Board's 19 recommendations start with basics: keep an accurate list of IT assets and applications, invest in tools that find vulnerable systems, and have a written vulnerability response process. It also called for better Software Bills of Materials (SBOMs), lists of the components inside a piece of software. The Board noted that none of the SBOM users it spoke to had actually used them to find Log4j, because formats varied and lacked version details.

The second lesson was about open source and the network. Log4j was maintained by a small group of volunteers, and the Board called for more investment in open source security and maintenance support for critical projects. Teams that could not patch at once relied on egress filtering, blocking outbound traffic the server does not need, and on removing the JndiLookup class. Those measures bought time, but the Board warned that organizations must also stop old vulnerable versions from coming back in later builds.

The case

Log4Shell: The Rewards Server

  1. Find what the advisory affects
  2. Were we hit?
  3. Stop it without switching rewards off
  4. Remove what they left
Investigate it hands-on

Questions

Which Log4j versions are affected by Log4Shell?

Log4j 2.0-beta9 to 2.14.1, apart from the security releases for older Java versions. Log4j 1.x is not affected by this CVE, though it is out of support.

Is blocking the attacker's address enough?

No. Exploitation comes from many addresses with disguised strings. Upgrade Log4j, and until then block the server's outbound connections so the callback cannot complete.

Is Log4Shell still a threat?

Yes. CISA listed it among the most routinely exploited vulnerabilities of 2023, and the Cyber Safety Review Board expects vulnerable copies to remain for a decade or longer. Sonatype reported that downloads of vulnerable Log4j versions were still above 10% nearly three years after fixes came out.

Has Log4Shell been patched?

Yes. Apache fixed it in 2.15.0 on 10 December 2021, then closed follow-up flaws in 2.16.0, 2.17.0 and 2.17.1. Every product that bundles Log4j also needs its own update, so a patch from Apache does not mean every system is fixed.

How do I fix Log4Shell?

Upgrade log4j-core to the newest release for your Java version: on Java 8 or later that means 2.17.1 or later, and Apache's security page lists the security releases for Java 6 and 7. Install vendor updates for products that bundle it. If you cannot upgrade right away, remove the JndiLookup class and block outbound traffic from the server, then check for signs that someone got in before the fix.

How do I check if I am vulnerable to Log4Shell?

Scan your servers and software for log4j-core JAR files, including ones nested inside other archives, and check their versions. CISA's advisory lists free scanners and file hash lists for this. Ask the vendors of closed products whether they include Log4j.

Is Log4j still used?

Yes. Apache still maintains Log4j 2 as a Java logging framework and keeps publishing releases; version 2.26.1 came out in June 2026. Using Log4j is safe on a current version. The risk is in old, unpatched copies.

What is JNDI in Log4Shell?

JNDI, the Java Naming and Directory Interface, is a Java feature for looking up objects in directory services such as LDAP. Log4j let log messages trigger a JNDI lookup, so a logged string could make the server fetch and load an object from an attacker's server.