Skip to content
RCE Write-up Intermediate

Log4Shell (CVE-2021–44228): The Log Injection Flaw That Shook t

Log4j 2 would resolve JNDI lookups in logged strings, so an attacker who could get a crafted string logged could make the server fetch and deserialise a remote Java class. That allowed remote code execution without authentication or user interaction.

Md Faiyaz Khan Follow

Published on medium.com

In December 2021, the cybersecurity world witnessed what many consider one of the most severe vulnerabilities in recent history — CVE-2021–44228, popularly known as Log4Shell.

Md Faiyaz Khan, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Log4j 2 performed JNDI lookups on logged strings by default, allowing attacker-controlled input to trigger a remote class load and deserialisation.

Impact

An attacker could achieve remote code execution on the target system without authentication or user interaction, and the flaw affected a very wide range of Java applications.

What the attacker needed

Attacker can get input logged; vulnerable Log4j 2 version; outbound LDAP/RMI allowed

The fix

Apache released patches: Log4j 2.15.0 disabled JNDI lookups by default, and later versions removed the lookup mechanism entirely; defenders were also advised to upgrade, set log4j2.formatMsgNoLookups=true, monitor logs, and block outbound LDAP and RMI traffic.

How it was found

  1. Send a crafted input containing a JNDI lookup string, such as in a login username.
  2. The vulnerable application logs the input.
  3. Log4j processes the lookup string and contacts the attacker's LDAP server.
  4. The attacker's server responds with a malicious Java class, which Log4j loads and executes.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Log4j is a helper library that Java programs use to write log messages. It had a feature that would fetch and run code from a web address if a log message contained a special pattern. An attacker could put that pattern into something like a username, and the server would run the attacker's code.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.