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.
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.
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
- Set up the vulnerable Log4Shell application using Docker.
- Start an LDAP server using Marshalsec to serve a malicious Java class.
- Create and compile a malicious Java class file that executes a command.
- Start a Python HTTP server to host the compiled class file.
- Craft a JNDI payload and send it via the X-Api-Version header using curl.
- 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.