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
jee web project with sanitised log4shell (CVE-2021-44228) vulnerability
Readme
## log4shell false positive

This is a simple web project with a sanitised log4shell vulnerability. For an unsanitised version, see [https://github.com/scabench/l4j-tp1/](https://github.com/scabench/l4j-tp1/).
The project defines a simple `scabench.HelloWorldService` get service returning a plain text string `hello world`.
The service does not expect parameters, and if parameters are encountered, an error 
is logged. 

The vulnerable dependency is [org.apache.logging.log4j:log4j-core:2.14.1](https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core/2.14.1), the vulnerability is [CVE-2021-44228](https://nvd.nist.gov/vuln/detail/CVE-2021-44228). 

### Sanitisation

The project uses an [agent build by Amazon](https://github.com/corretto/hotpatch-for-apache-log4j2) when *log4shell* emerged and no patch was available.
The agent will disable the vulnerable class `org.apache.logging.log4j.core.lookup.JndiLookup`. 

Using the agent is enforced by installing (aka attaching) the agent dynamically when `scabench.HelloWorldService` is loaded (in the static block of the class), 
if this fails, the application crashes. This requires that the JVM enables agent self-attachment.


### Running the Application

1. enable JVM agent self attachment: `export MAVEN_OPTS="-Djdk.attach.allowAttachSelf=true"`
2. start the embedded web server: `mvn jetty:run`
3. start the included the ldap server: `java -jar dodgy-ldap-server.jar` (the vulnerable copde will download Java code from this server)
4. point the browser to `http://localhost:8080/`, this site contains a pre-populated form with a malicious payload `${jndi:ldap://127.0.0.1/exe}`
5. submit this form
6. this will *NOT* create the file `foo` on the server (as the [un-sanitised version]((https://github.com/scabench/l4j-tp1/)) does)


Note that when running the application, the following line appears on the console:

`Transforming org/apache/logging/log4j/core/lookup/JndiLookup `.

### Demonstrating the Sanitisation using a Test

This requires unix or macos. It is easy to port this project to windows.
A unit test is provided to demonstrate the vulnerability, the setup is the same used in 
[https://github.com/scabench/l4j-tp1/](https://github.com/scabench/l4j-tp1/). Due to santitisation,
the test now *fails*. 

### Running Software Composition Analyses

There are several sh scripts to run different analyses, result resports can be found in `scan-results`.

### Generating the SBOM

The `pom.xml` has a plugin to generate a [SBOM](https://www.cisa.gov/sbom) in [CycloneDX](https://cyclonedx.org/) format. 
To do this, run `mvn cyclonedx:makePackageBom`, the SBOM can be found in 
`target/` in `json` and `xml` format.

File Snapshot

[4.0K] /data/pocs/f805f538cee398ccb5a453dabe6e47c186db74a7 ├── [ 11K] LICENSE ├── [136K] Log4jHotPatch.jar ├── [4.4K] pom.xml ├── [2.6K] README.md ├── [ 452] run-owasp.sh ├── [ 261] run-snyk.sh ├── [4.0K] scan-results │   ├── [4.0K] dependency-check │   │   └── [156K] dependency-check-report.json │   └── [4.0K] snyk │   └── [ 27K] snyk-report.json └── [4.0K] src ├── [4.0K] main │   ├── [4.0K] java │   │   └── [4.0K] scabench │   │   └── [2.8K] HelloWorldService.java │   └── [4.0K] webapp │   └── [ 364] index.html └── [4.0K] test └── [4.0K] java └── [4.0K] scabench └── [1.9K] Log4ShellTest.java 11 directories, 11 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 →