Skip to content
RCE Write-up Intermediate

Exploiting Log4Shell — How Log4J Applications Were Hacked

Log4Shell is a critical remote code execution vulnerability in Apache Log4j where an attacker can inject a JNDI lookup string that causes the application to fetch and execute a malicious Java class from an attacker-controlled server. This allows arbitrary code execution on the vulnerable server.

MrXcrypt Follow

Published on infosecwriteups.com

Log4Shell is a critical Remote Code Execution (RCE) vulnerability in the Apache Log4j logging framework. It went unnoticed for nearly eight years, since 2013, before its public disclosure in 2021.

MrXcrypt, on infosecwriteups.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 lookup feature, specifically JNDI lookups, processes user-controlled input without proper validation, allowing remote code execution.

Impact

An attacker could execute arbitrary code on the server, potentially gaining full control over the system.

What the attacker needed

Vulnerable Log4j version; user-controlled input logged; attacker-controlled LDAP server; malicious Java class file

How it was found

  1. Set up the vulnerable Log4Shell application using Docker.
  2. Start an LDAP server using Marshalsec to serve a malicious Java class.
  3. Create and compile a malicious Java class file that executes a command.
  4. Start a Python HTTP server to host the compiled class file.
  5. Craft a JNDI payload and send it via the X-Api-Version header using curl.
  6. Verify exploit execution by checking for the created file in the container's /tmp directory.

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 can look up values from other systems, and if an attacker can control what gets logged, they can trick Log4j into fetching and running harmful code from the attacker's server. This gives the attacker control over the vulnerable server.

What is RCE?

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

More by MrXcrypt

View all

1 more disclosed report, best first.

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.