Skip to content
RCE Write-up Intermediate

Inside the log4j2 vulnerability (CVE-2021-44228)

A critical vulnerability in the Log4j 2 Java logging library allows an attacker to execute arbitrary code on a remote server by causing a malicious string to be logged. The flaw arises because Log4j's JNDI lookup feature can be tricked into connecting to an attacker-controlled LDAP server and loading a malicious object.

blog.cloudflare.com

Published on blog.cloudflare.com

Yesterday, December 9, 2021, a very serious vulnerability in the popular Java-based logging package Log4j was disclosed. This vulnerability allows an attacker to execute code on a remote server; a so-called Remote Code Execution (RCE).

The author, on blog.cloudflare.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's JNDI lookup feature evaluates attacker-controlled strings in log messages, allowing connections to arbitrary LDAP servers and loading of remote objects.

What the attacker needed

Log4j 2 version between 2.0-beta-9 and 2.14.1; Attacker can control a logged input; Attacker controls an LDAP server

The fix

Upgrade to Log4j 2.16.0 (or 2.12.2 for Java 7), or remove the JndiLookup class from the classpath.

How it was found

  1. Find an input that gets logged, such as an HTTP header or form parameter.
  2. Insert a string that triggers a JNDI lookup to an attacker-controlled server.
  3. The Log4j library processes the lookup and connects to the attacker's LDAP server.
  4. The LDAP server returns a malicious object that is loaded and executed.

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 tool that Java programs use to write log messages. It has a feature that lets log messages include special commands, like looking up data from another server. An attacker can sneak such a command into something that gets logged, like a username, and trick the program into downloading and running malicious code from the attacker's server.

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.