~/security/log4j-zero-day-security-vulnerability-solution-cve.md

Log4j Zero-Day Vulnerability Explained (CVE-2021-44228)

2 min readDecember 15, 2021by Gorav Singal#security#issues#java
// TL;DR

The Log4j zero-day vulnerability (CVE-2021-44228, CVE-2021-45046) allows remote code execution via JNDI lookups; upgrade to patched Log4j versions to remediate.

Log4j Zero-Day Vulnerability Explained (CVE-2021-44228)

Introduction

On 9th December 2021, an industry-wide vulnerability was discovered that specifically affect the Apache Log4j Java library.

The security vulnerability allows an attacker (Hacker) to achieve Remote Code Execution (RCE) on a host.

See the detailed Vulnerability CVE

What it Means

It’s important to note that Apache log4j is a Java package which indicates any platform/application using Java is potentially at risk. This is a fast moving exploit with exploit code being released in the wild after few days this vulnerability was found and Apache has now published a patch to remediate the vulnerability.

Affected Version and a Fix in Hurry

Following versions are affected:

2.0-beta9 <= Apache log4j <= 2.15.0

They initially suggested to migrate it to 2.15. But, as soon as they released. Next day, another security vulnerability popped up.

The Fix

Now, the safe version you need to move is: 2.16.0

The best way to mitigate from this vulnerability is to upgrade to 2.16.0.

If by any chance, you are not able to upgrade to this library version. It is recommended to ensure that you are setting a system property on both client side and server side:

log4j2.formatMsgNoLookups=true

What about People using 1.x

Note: This vulnerability is only affecting log4k library 2.0-beta9 <= Apache log4j <= 2.15.0 So, 1.x is actually safe. But, you should always plan to migrate to the latest libraries.

What was the Vulnerability

This could allows attackers with control over Thread Context Map (MDC) input data when the logging configuration uses a non-default Pattern Layout with either a Context Lookup (for example, $${ctx:loginId}) or a Thread Context Map pattern to craft malicious input data using a JNDI Lookup pattern resulting in a denial of service (DOS) attack.

Log4j 2.15.0 restricts JNDI LDAP lookups to localhost by default. Note that previous mitigations involving configuration such as to set the system property log4j2.noFormatMsgLookup to true do NOT mitigate this specific vulnerability. Log4j 2.16.0 fixes this issue by removing support for message lookup patterns and disabling JNDI functionality by default. This issue can be mitigated in prior releases (<2.16.0) by removing the JndiLookup class from the classpath (example: zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class).

Maven Libraries to use

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.16.0</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.16.0</version>
</dependency>

Hurry Up

Companies are in hurry to fix this ASAP. As, they understand its impact. Almost, everybody is working on upgrading these libraries.

Resources

$ subscribe --weekly

One deep dive a week, in your inbox

System design, AI engineering, trading systems and interview prep. Tested code, real numbers. Free, and you can unsubscribe any time.

or read it on gyanbyte.substack.com

Share

Related Posts

SQL Injection: The Complete Guide to Understanding, Preventing, and Detecting SQLi Attacks

SQL Injection: The Complete Guide to Understanding, Preventing, and Detecting SQLi Attacks

SQL injection has been on the OWASP Top 10 since the list was created in 200…

Software Security in the AI Era: How to Write Secure Code When AI Writes Code Too

Software Security in the AI Era: How to Write Secure Code When AI Writes Code Too

In 2025, 72% of professional developers used AI-assisted coding tools daily. By…

Building a Vulnerability Detection System That Developers Actually Use

Building a Vulnerability Detection System That Developers Actually Use

Here’s a stat that should concern every security team: 73% of developers say…

Java Log4j Logger - Programmatically Initialize JSON logger with customized keys in json logs

Java Log4j Logger - Programmatically Initialize JSON logger with customized keys in json logs

Introduction Java log4j has many ways to initialize and append the desired…

Python SMTP Email Code - Sender Address Rejected - Not Owned By User

Python SMTP Email Code - Sender Address Rejected - Not Owned By User

Introduction In a normal email sending code from python, I’m getting following…

Cyberark Rest API Certificate based Authentication - Curl Command to Fetch Credentials

Cyberark Rest API Certificate based Authentication - Curl Command to Fetch Credentials

Introduction Cyberark kind of tools are a must for security in your…

Latest Posts

How to Stay Valuable as a Software Engineer in the AI Era: A Practical Playbook

How to Stay Valuable as a Software Engineer in the AI Era: A Practical Playbook

In the previous article I argued that AI is not killing software engineering…

How to Review AI-Generated Code: A Checklist for Catching What the Model Missed

How to Review AI-Generated Code: A Checklist for Catching What the Model Missed

A few months back I approved a PR that was almost entirely AI-generated. It…

How to Debug AI-Generated Code: Understand First, Fix Last

How to Debug AI-Generated Code: Understand First, Fix Last

In the last article I wrote about reviewing AI code before it goes in. This one…

The Future of Software Engineering: What AI Changes, What Stays, and Where the Jobs Go

The Future of Software Engineering: What AI Changes, What Stays, and Where the Jobs Go

Every few weeks somebody sends me a scary headline — “AI will replace all…

The Transactional Outbox Pattern: Never Lose an Event Again

The Transactional Outbox Pattern: Never Lose an Event Again

This is one of those patterns that looks like nothing until you get burnt once…

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Event Sourcing, Explained: Store What Happened, Not Just the Final State

Here is a question I like to ask in interviews: your bank account shows a…