Skip to content

fix: pin fastjson to 1.2.83_noneautotype for autoType RCE protection - #2

Closed
CH3CHO wants to merge 3 commits into
mainfrom
fix/fastjson-rce-cve
Closed

CH3CHO wants to merge 3 commits into
mainfrom
fix/fastjson-rce-cve

Conversation

@CH3CHO

@CH3CHO CH3CHO commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

将 com.alibaba:fastjson 由 1.2.83 升级到 1.2.83_noneautotype,从字节码层拆除 @type/autoType 反序列化代码路径,消除历史 fastjson RCE gadget chains。

Changes

  • backend/pom.xml:60 — <fastjson.version> 从 1.2.83 改为 1.2.83_noneautotype
  • backend/console/src/test/java/com/alibaba/higress/console/security/FastjsonAutotypeGuardTest.java — 新增回归单测

Why 1.2.83_noneautotype

1.2.83_noneautotype 是阿里在 Maven Central 发布的同源代码、构建期剥离 autoType 处理的官方变体(com.alibaba:fastjson:1.2.83_noneautotype,Apache 2.0)。它把 ParserConfig.checkAutoType 整段替换为 throw new JSONException("safeMode not support autoType : " + typeName),比 ParserConfig.safeMode = true 更彻底——即使代码中显式使用 ParserConfig 也无路径可走。

API 类(com.alibaba.fastjson.JSON、JSONObject、JSONArray)入口与 1.2.83 完全一致;序列化路径(toJSONString)不受影响。所有 DAO/Service 调用点不调整。

Test Plan

  • ./mvnw -pl console -am test -Dmaven.gitcommitid.skip=true — console 2/2 pass (新守卫测试)
  • ./mvnw -pl sdk -am test -Dmaven.gitcommitid.skip=true — sdk 252/252 pass (无回归)
  • 工作树干净,仅 1 commit (squash 前置完成)

Rand01ph and others added 3 commits July 17, 2026 19:16
…ut in provider form (higress-group#732)

Signed-off-by: Rand01ph <tanyawei1991@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…reload (higress-group#749)

Signed-off-by: ShadowSmallBaby <43118517+ShadowSmallBaby@users.noreply.github.com>
- Bump <fastjson.version> from 1.2.83 to 1.2.83_noneautotype.
- 1.2.83_noneautotype is an Alibaba-published variant of 1.2.83 that
  replaces ParserConfig.checkAutoType with a blanket throw, eliminating
  the historical fastjson RCE gadgets by construction rather than by
  configuration.
- Add FastjsonAutotypeGuardTest to lock the protection in CI: any future
  downgrade to a fastjson build that re-enables autoType will fail this
  test.

Note on the test: @type=java.util.Date is used as the probe because
HashMap and LinkedHashMap are handled by a hardcoded branch in
DefaultJSONParser that runs BEFORE checkAutoType and is not modified
by _noneautotype. Date is a basic JDK class that is not in the
hardcoded branch, not in fastjson's deny list, and has a no-arg
constructor, so it exercises the checkAutoType path.

In 1.2.83, the test fails because the exception message is
"syntax error" (checkAutoType allows Date, instance is created via
reflection, then setting the unknown "foo" property fails). In
1.2.83_noneautotype, the test passes because checkAutoType throws
"safeMode not support autoType : java.util.Date" -- the message
contains "autoType" which the test asserts.
@CH3CHO CH3CHO closed this Jul 25, 2026
@CH3CHO
CH3CHO deleted the fix/fastjson-rce-cve branch July 25, 2026 02:24
@CH3CHO
CH3CHO restored the fix/fastjson-rce-cve branch July 25, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants