Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-44228 PoC — Apache Log4j2 JNDI features do not protect against attacker controlled LDAP and other JNDI related endpoints

Source
Associated Vulnerability
Title:Apache Log4j2 JNDI features do not protect against attacker controlled LDAP and other JNDI related endpoints (CVE-2021-44228)
Description:Apache Log4j2 2.0-beta9 through 2.15.0 (excluding security releases 2.12.2, 2.12.3, and 2.3.1) JNDI features used in configuration, log messages, and parameters do not protect against attacker controlled LDAP and other JNDI related endpoints. An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled. From log4j 2.15.0, this behavior has been disabled by default. From version 2.16.0 (along with 2.12.2, 2.12.3, and 2.3.1), this functionality has been completely removed. Note that this vulnerability is specific to log4j-core and does not affect log4net, log4cxx, or other Apache Logging Services projects.
Description
A short demo of CVE-2021-44228
Readme

# sample-ldap-exploit

A short demo of CVE-2021-44228 

## Build

~~~
$ mvn clean verify
~~~

## Run Attacker

~~~
$ java \
  -cp 'attacker/target/sample-attacker.jar:attacker/target/lib/*' \
  sample.attacker.Attacker localhost 1389 sample.payload.Payload 8080 payload/target/sample-payload.jar
~~~

URLs:
- `http://localhost:8080/`
- `http://localhost:8080/sample/payload/Payload.class` 

## Run Victim

~~~
$ java \
  -cp 'victim/target/sample-victim.jar:victim/target/lib/*' \
  sample.victim.Victim
~~~

## Results

### JDK / JRE

| Version                          | Status                                                                     |
|----------------------------------|----------------------------------------------------------------------------|
| `Oracle JDK 8u5`                 | vulnerable                                                                 |
| `OpenJDK 8u312`                  | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |
| `IBM OpenJDK 8u312-b07 (OpenJ9)` | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |
| `OpenJDK 11.0.7+10`              | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |
| `OpenJDK 11.0.13+8`              | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |
| `OpenJDK 16+36`                  | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |
| `OpenJDK 17+35`                  | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |
| `OpenJDK 17.0.1+12`              | NOT vulnerable (unless `-Dcom.sun.jndi.ldap.object.trustURLCodebase=true`) |

If NOT vulnerable, an instance of `javax.naming.Reference` is returned from `javax.naming.Context.lookup()`.

If NOT vulnerable to loading classes from remote code bases,
other **Java deserialization vulnerabilities probably still exist**!

### log4j

| Version  | Status                                                                                                            |
|----------|-------------------------------------------------------------------------------------------------------------------|
| `2.9.1`  | vulnerable                                                                                                        |
| `2.10.0` | vulnerable (unless `-Dlog4j2.formatMsgNoLookups=true` or environment variable `LOG4J_FORMAT_MSG_NO_LOOKUPS=true`) |
| `2.14.1` | vulnerable (unless `-Dlog4j2.formatMsgNoLookups=true` or environment variable `LOG4J_FORMAT_MSG_NO_LOOKUPS=true`) |
| `2.15.0` | NOT vulnerable                                                                                                    |

If NOT vulnerable, `${jndi:ldap:...}` is NOT resolved.
File Snapshot

[4.0K] /data/pocs/4da7d204bd3be540b799d95159b6b6929e1e3808 ├── [4.0K] attacker │   ├── [1.8K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   └── [4.0K] java │   └── [4.0K] sample │   └── [4.0K] attacker │   ├── [2.9K] Attacker.java │   └── [1.8K] ReferenceInterceptor.java ├── [4.0K] payload │   ├── [ 789] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   └── [4.0K] java │   └── [4.0K] sample │   └── [4.0K] payload │   └── [ 719] Payload.java ├── [ 569] pom.xml ├── [2.7K] README.md └── [4.0K] victim ├── [1.5K] pom.xml └── [4.0K] src └── [4.0K] main └── [4.0K] java └── [4.0K] sample └── [4.0K] victim └── [ 532] Victim.java 18 directories, 9 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →