What is CVE-2021-45046 and why is it so dangerous?
Log4shell boils down to the following:
- Logs are an integral part of an application. They document any important event and action that happens within their embedding app, including actions of the application’s users.
- This means that in some part of an app, user-provided input is logged, and that any user has the ability to control a portion of an application’s log.
- Log4j enabled a feature that let it parse and interpret logs that contain requests to remote servers. This was added as a way to create dynamic content in a log.
The above three points combined form a fatal combination from an app’s perspective:
Any user is most likely able to control some portion of an application’s log, and include an arbitrary call to any remote server, forcing the application to execute any data the remote server responds with.
Log4j Vulnerability CVE-2021-45046 Now a Critical 9.0 | WhiteSource
How CVE-2021-45046 works
The third item above actually consists of two steps:
- parsing and executing the log
- requesting the remote server
Refer to a more technical description of the vulnerability:
It was found that the fix to address CVE-2021-44228 in Apache Log4j 2.15.0 was incomplete in certain non-default configurations. When the logging configuration uses a non-default Pattern Layout with a Context Lookup (for example, $${ctx:loginId}), attackers with control over Thread Context Map (MDC) input data can craft malicious input data using a JNDI Lookup pattern, resulting in an information leak and remote code execution in some environments and local code execution in all environments; remote code execution has been demonstrated on macOS but no other tested environments.
Log4j – Apache Log4j Security Vulnerabilities
We have:
- parsing and executing the log:
${ some_danger_cmd }
which is called message lookups
- requesting the remote server: by using JNDI (Java Naming and Directory Interface) Lookup pattern
Both of these are critical steps in vulnerability exploitation, and blocking either of them can mitigate the vulnerability.
In fact Apache’s mitigation and vulnerability remediation does the same thing.
Log4j 2.x mitigation
Implement one of the following mitigation techniques:
- Java 8 (or later) users should upgrade to release 2.16.0.
- Java 7 users should upgrade to release 2.12.2.
- Otherwise, in any release other than 2.16.0, you may remove the JndiLookup class from the classpath: zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
Users are advised not to enable JNDI in Log4j 2.16.0. If the JMS Appender is required, use Log4j 2.12.2.
Release Details
From version 2.16.0 (for Java 8), the message lookups feature has been completely removed. Lookups in configuration still work.
Furthermore, Log4j now disables access to JNDI by default. JNDI lookups in configuration now need to be enabled explicitly. Users are advised not to enable JNDI in Log4j 2.16.0. If the JMS Appender is required, use Log4j 2.12.2.
Log4j – Apache Log4j Security Vulnerabilities
So is Log4jl.jl safe?
Log4jl.jl hasn’t been updated in a long time, and I haven’t reviewed its code in detail, so I can’t make a judgment.
But Log4jl.jl does not call Java directly, nor does it implement JNDI.
In principle, it can’t call a program at any remote address.
Although Log4jl.jl claims to have an architecture similar to Log4j, I think the architecture here is mainly the design of the API interface. Rather than having a similar internal implementation.
In general, I prefer that Log4jl.jl is not affected by CVE-2021-45046.