CVE-2021-44228: Apache log4j2 log messages substitution (CVE-2021-44228)
Summary
Log4j versions prior to 2.16.0 are subject to a remote code execution vulnerability via the ldap JNDI parser. As per Apache's Log4j security guide: Apache Log4j2 <=2.14.1 JNDI features used in configuration, log messages, and parameters do not protect against attacker controlled LDAP and other JNDI related endpoints. 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. From log4j 2.16.0, this behavior has been disabled by default.
Log4j version 2.15.0 contained an earlier fix for the vulnerability, but that patch did not disable attacker-controlled JNDI lookups in all situations. For more information, see the Updated advice for version 2.16.0 section of this advisory.
Impact
Logging untrusted or user controlled data with a vulnerable version of Log4J may result in Remote Code Execution (RCE) against your application. This includes untrusted data included in logged errors such as exception traces, authentication failures, and other unexpected vectors of user controlled input.
Affected versions
Any Log4J version prior to v2.15.0 is affected to this specific issue.
The v1 branch of Log4J which is considered End Of Life (EOL) is vulnerable to other RCE vectors so the recommendation is to still update to 2.16.0 where possible.
Security releases Additional backports of this fix have been made available in versions 2.3.1, 2.12.2, and 2.12.3
Affected packages Only the org.apache.logging.log4j:log4j-core package is directly affected by this vulnerability. The org.apache.logging.log4j:log4j-api should be kept at the same version as the org.apache.logging.log4j:log4j-core package to ensure compatability if in use.
Remediation Advice
Updated advice for version 2.16.0
The Apache Logging Services team provided updated mitigation advice upon the release of version 2.16.0, which disables JNDI by default and completely removes support for message lookups. Even in version 2.15.0, lookups used in layouts to provide specific pieces of context information will still recursively resolve, possibly triggering JNDI lookups. This problem is being tracked as CVE-2021-45046. More information is available on the GitHub Security Advisory for CVE-2021-45046.
Users who want to avoid attacker-controlled JNDI lookups but cannot upgrade to 2.16.0 must ensure that no such lookups resolve to attacker-provided data and ensure that the the JndiLookup class is not loaded.
Please note that Log4J v1 is End Of Life (EOL) and will not receive patches for this issue. Log4J v1 is also vulnerable to other RCE vectors and we recommend you migrate to Log4J 2.16.0 where possible.
Other sources
A flaw was found in the Java logging library log4j which could allow a remote attacker to execute code on the server if the system logs an attacker controlled string value. This affects versions between 2.0 <= and <= 2.14.1.
— Red Hat
A flaw was found in the Apache Log4j logging library in versions from 2.0.0 and before 2.15.0. A remote attacker who can control log messages or log message parameters, can execute arbitrary code on the server via JNDI LDAP endpoint.
Apache Log4j <=2.14.1 JNDI features used in configuration, log messages, and parameters do not protect against attacker controlled LDAP and other JNDI related endpoints. 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 (CVE-2021-44228).
— FortiGuard
Apache Log4j2 2.0-beta9 through 2.15.0 (excluding security releases 2.12.2, 2.12.3, and 2.3.1) JNDI features used in configuration, log messages, and parameters do not protect against attacker controlled LDAP and other JNDI related endpoints. 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. From log4j 2.15.0, this behavior has been disabled by default. From version 2.16.0 (along with 2.12.2, 2.12.3, and 2.3.1), this functionality has been completely removed. Note that this vulnerability is specific to log4j-core and does not affect log4net, log4cxx, or other Apache Logging Services projects.
Apache Log4j2 contains a vulnerability where JNDI features do not protect against attacker-controlled JNDI-related endpoints, allowing for remote code execution.
— CISA
Credit
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/apache-log4j1.2to a version that resolves this vulnerability.Fixed in 1.2.17-8+deb10u2Fixed in 1.2.17-8+deb10u1Fixed in 1.2.17-10+deb11u1Fixed in 1.2.17-11 - Upgrade
Upgrade
debian/apache-log4j2to a version that resolves this vulnerability.Fixed in 2.17.1-1~deb10u1Fixed in 2.17.0-1~deb10u1Fixed in 2.17.1-1~deb11u1Fixed in 2.17.0-1~deb11u1Fixed in 2.19.0-2 - Upgrade
Upgrade
debian/apache-log4j2to a version that resolves this vulnerability.Fixed in 2.15.0-1Fixed in 2.15.0-1~deb11u1Fixed in 2.15.0-1~deb10u1 - Upgrade
Upgrade
Apple Xcodeto a version that resolves this vulnerability.Fixed in 13.3 - Upgrade
Upgrade
maven/org.ops4j.pax.logging:pax-logging-log4j2to a version that resolves this vulnerability.Fixed in 2.0.11 - Upgrade
Upgrade
maven/org.ops4j.pax.logging:pax-logging-log4j2to a version that resolves this vulnerability.Fixed in 1.11.10 - Upgrade
Upgrade
maven/org.ops4j.pax.logging:pax-logging-log4j2to a version that resolves this vulnerability.Fixed in 1.10.8 - Upgrade
Upgrade
maven/org.ops4j.pax.logging:pax-logging-log4j2to a version that resolves this vulnerability.Fixed in 1.9.2 - Upgrade
Upgrade
maven/org.apache.logging.log4j:log4j-coreto a version that resolves this vulnerability.Fixed in 2.3.1 - Upgrade
Upgrade
maven/org.apache.logging.log4j:log4j-coreto a version that resolves this vulnerability.Fixed in 2.12.2 - Upgrade
Upgrade
maven/org.apache.logging.log4j:log4j-coreto a version that resolves this vulnerability.Fixed in 2.15.0 - Upgrade
Upgrade
redhat/log4jto a version that resolves this vulnerability.Fixed in 2.15.0 - Upgrade
Upgrade
org.apache.logging.log4j:log4j-coreto a version that resolves this vulnerability.Fixed in 2.16.0 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch CVE-2021-45046 - Remove
Remove
org.apache.logging.log4j:log4j-core org/apache/logging/log4j/core/lookup/JndiLookup.classfrom your environment.Remove the JndiLookup class from the classpath by deleting org/apache/logging/log4j/core/lookup/JndiLookup.class from log4j-core-*.jar (e.g., via zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class).
- Configuration
Set the system property log4j2.formatMsgNoLookups (or environment variable LOG4J_FORMAT_MSG_NO_LOOKUPS) to true to prevent attacker-controlled message lookups.
Apache Log4j2 log4j2.formatMsgNoLookups = true - Configuration
Modify all PatternLayout patterns to specify the message converter as %m{nolookups} instead of just %m.
Apache Log4j2 PatternLayout message converter pattern = %m{nolookups}
Event History
Parent advisories
This vulnerability appears in the following advisories.
- RHSA-2021:5137
- RHSA-2021:5128
- RHSA-2021:5127
- RHSA-2021:5129
- RHSA-2021:5133
- RHSA-2021:5138
- RHSA-2021:5132
- RHSA-2021:5130
- RHSA-2021:5126
- RHSA-2021:5140
- RHSA-2021:5134
- RHSA-2022:0203
- RHSA-2021:5094
- RHSA-2021:5106
- RHSA-2021:5141
- RHSA-2021:5107
- RHSA-2021:5108
- RHSA-2021:5148
- RHSA-2022:0082
- RHSA-2022:0296
- RHSA-2021:5093
- HT213189
Peer vulnerabilities
Found alongside the following vulnerabilities.
Frequently Asked Questions
What is CVE-2021-44228?
CVE-2021-44228 is a remote code execution vulnerability in Apache Log4j2.
How severe is CVE-2021-44228?
CVE-2021-44228 is classified as critical with a severity value of 10.
Which software is affected by CVE-2021-44228?
Apache Log4j2 versions prior to 2.16.0 are affected by CVE-2021-44228.
How can I fix CVE-2021-44228?
To fix CVE-2021-44228, upgrade to Apache Log4j2 version 2.16.0 or later.
Where can I find more information about CVE-2021-44228?
You can find more information about CVE-2021-44228 at the following references: [CVE.org](https://www.cve.org/CVERecord?id=CVE-2021-44228), [NVD](https://nvd.nist.gov/vuln/detail/CVE-2021-44228), [GitHub Advisory](https://github.com/advisories/GHSA-jfh8-c2jp-5v3q), [Apache Log4j Security Guide](https://logging.apache.org/log4j/2.x/security.html), [Lunasec Blog](https://www.lunasec.io/docs/blog/log4j-zero-day/), [Red Hat Bugzilla](https://bugzilla.redhat.com/show_bug.cgi?id=2030932), and [Red Hat Advisory](https://access.redhat.com/errata/RHSA-2021:5137).