Skip to content

Security Advisory: Remote Code Execution in fastjson 1.2.68–1.2.83

Shaojin Wen edited this page Jul 21, 2026 · 2 revisions

Security Advisory: Remote Code Execution in fastjson 1.2.68–1.2.83

安全公告:fastjson 1.2.68–1.2.83 远程代码执行漏洞

Date / 发布日期:2026-07-21 Severity / 严重等级:🔴 Critical / 严重 Affected / 影响版本:fastjson 1.2.68 – 1.2.83 (including 1.2.83, the last 1.x release / 含 1.2.83,即 1.x 最后一个版本) Not affected / 不影响:All fastjson2 versions / fastjson2 所有版本


English

Summary

A remote code execution (RCE) vulnerability exists in fastjson 1.2.68 through 1.2.83. This vulnerability is exploitable under fastjson's stock default configuration — no AutoType enablement required, no classpath gadget required.

The only deployment prerequisite is that the target runs as a Spring Boot executable fat-jar (i.e., launched via java -jar xxx.jar). This is the most common Spring Boot deployment model.

Verified end-to-end on Spring Boot 2.x / 3.x / 4.x and JDK 8 / 11 / 17 / 21.

Affected

Condition Detail
fastjson version 1.2.68 – 1.2.83
Configuration AutoType OFF + SafeMode OFF (stock defaults)
Deployment Spring Boot executable fat-jar
JDK 8 / 11 / 17 / 21 verified
Spring Boot 2.x / 3.x / 4.x verified
Entry points JSON.parse, JSON.parseObject(String), JSON.parseObject(String, Class) all reachable

⚠️ Specifying a target class (e.g., JSON.parseObject(body, SomeDto.class)) is not a mitigation — attackers can nest payloads inside Object/Map-typed fields of the DTO.

Not Affected

Condition Reason
All fastjson2 versions Root cause architecturally eliminated
SafeMode = true Rejects all @type before the vulnerable path is reached
noneautotype builds Vulnerable code removed at compile time
Non-fat-jar deployments plain java -jar, uber-jar, Tomcat/Jetty WAR do not meet the trigger condition
fastjson ≤ 1.2.60 Vulnerable code path does not exist

fastjson2 Is Not Affected

fastjson2 architecturally eliminates the root cause of this vulnerability:

  • No resource probing: The type resolution path contains no getResourceAsStream call on user-controlled class names; class loading uses only ClassLoader.loadClass() and Class.forName()
  • No annotation-based trust bypass: The @JSONType annotation is used solely for serialization configuration, not as a trust signal in type resolution
  • Allowlist-first model: Types must match an allowlist or be explicitly approved by an AutoTypeBeforeHandler; otherwise they are rejected with no secondary escape path
  • autoType disabled by default: SupportAutoType is off by default, deprecated, and carries a security warning

fastjson2 users need take no action regarding this vulnerability.

Remediation

fastjson 1.x users

Priority Action Detail
P0 Enable SafeMode -Dfastjson.parser.safeMode=true, or ParserConfig.getGlobalInstance().setSafeMode(true), or set in fastjson.properties
P0 Or switch to a noneautotype build Maven example: com.alibaba:fastjson:1.2.83_noneautotype
P1 Migrate to fastjson2 Architecturally eliminates this vulnerability; safe under default configuration

fastjson2 users

No action required for this vulnerability. General security practices:

  • Do not explicitly enable JSONReader.Feature.SupportAutoType (deprecated)
  • If autoType capability is genuinely needed, use ContextAutoTypeBeforeHandler with a strict allowlist

Acknowledgements

We thank Kirill Firsov of FearsOff Cybersecurity for discovering and responsibly disclosing this vulnerability.


中文

概述

fastjson 1.2.68 至 1.2.83 存在一条远程代码执行(RCE)漏洞。该漏洞在 fastjson 的默认配置下即可触发——无需开启 AutoType,无需 classpath 上存在任何 gadget 类。

唯一的部署前置条件是目标运行在 Spring Boot 可执行 fat-jar 模式下(即通过 java -jar xxx.jar 启动)。该模式是 Spring Boot 应用最常见的部署方式。

已在 Spring Boot 2.x / 3.x / 4.x,JDK 8 / 11 / 17 / 21 上完成端到端验证。

受影响

条件 说明
fastjson 版本 1.2.68 – 1.2.83
配置 AutoType OFF + SafeMode OFF(即默认配置
部署方式 Spring Boot 可执行 fat-jar
JDK 8 / 11 / 17 / 21 均验证
Spring Boot 2.x / 3.x / 4.x 均验证
入口 JSON.parseJSON.parseObject(String)JSON.parseObject(String, Class) 均可达

⚠️ 指定目标 Class(如 JSON.parseObject(body, SomeDto.class)不是缓解措施——攻击者可通过 DTO 中 Object / Map 类型的字段嵌套 payload。

不受影响

条件 原因
fastjson2 所有版本 架构上已消除此漏洞根因
SafeMode = true 在漏洞触发路径之前即拒绝所有 @type
noneautotype 版本 漏洞相关代码在编译期被移除
非 fat-jar 部署 plain java -jar、uber-jar、Tomcat/Jetty WAR 部署不满足触发条件
fastjson ≤ 1.2.60 不存在漏洞相关代码路径

fastjson2 不受影响

fastjson2 从架构上消除了此漏洞的根因:

  • 无资源探测:类型解析路径中不存在基于用户可控类名的 getResourceAsStream 调用,类加载仅使用 ClassLoader.loadClass()Class.forName()
  • 无注解信任绕过@JSONType 注解仅用于序列化配置,不作为类型解析的信任判据
  • 白名单优先:类型必须匹配白名单或经 AutoTypeBeforeHandler 显式批准,否则直接拒绝,无二次逃逸路径
  • autoType 默认关闭SupportAutoType 默认不启用,且已标记 @Deprecated 并附有安全警告

fastjson2 用户无需针对此漏洞采取任何行动。

修复建议

fastjson 1.x 用户

优先级 措施 说明
P0 启用 SafeMode -Dfastjson.parser.safeMode=true,或 ParserConfig.getGlobalInstance().setSafeMode(true),或在 fastjson.properties 中设置
P0 或切换 noneautotype 版本 Maven 坐标示例:com.alibaba:fastjson:1.2.83_noneautotype
P1 迁移至 fastjson2 从架构上消除此漏洞,且默认配置即安全

fastjson2 用户

无需针对此漏洞采取任何行动。一般性安全实践:

  • 避免显式启用 JSONReader.Feature.SupportAutoType(已废弃)
  • 如确需 autoType 能力,使用 ContextAutoTypeBeforeHandler 配置严格白名单

致谢

感谢 FearsOff Cybersecurity 的 Kirill Firsov 发现并负责任地披露了该漏洞。

Clone this wiki locally