# Java Framework Audit

Java 框架特定漏洞源码审计。当在 Java 白盒审计中需要检测框架层面的已知漏洞模式时触发。 覆盖 5 大框架/组件: Spring...

- Repository: https://github.com/wgpsec/AboutSecurity (1833 stars)
- Category: Data and ML
- License: see repository
- Last updated: 2026-10-24
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add wgpsec/AboutSecurity --skill java-framework-audit -g -a claude-code -y`
Codex: `npx skills add wgpsec/AboutSecurity --skill java-framework-audit -g -a codex -y`
Cursor: `npx skills add wgpsec/AboutSecurity --skill java-framework-audit -g -a cursor -y`
Gemini CLI: `npx skills add wgpsec/AboutSecurity --skill java-framework-audit -g -a gemini-cli -y`

## Description

Java 框架特定漏洞源码审计。当在 Java 白盒审计中需要检测框架层面的已知漏洞模式时触发。 覆盖 5 大框架/组件: Spring 全家桶(SpEL/Actuator/参数绑定/Spring Cloud Gateway)、 Struts2(OGNL/ActionMapping/Content-Type 解析)、Shiro(RememberMe 反序列化/URI 绕过)、 FastJSON/Jackson/Gson(反序列化 autotype/polymorphic)、MyBatis(${} 注入/动态 SQL)。 这些是 Java 生态中出现频率最高、影响面最广的框架级漏洞。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Java 框架特定漏洞源码审计
框架漏洞的本质分两类: **框架自身缺陷**（已知 CVE，升级即修）和**框架误用**（开发者对框架安全机制理解不足导致的配置/编码缺陷）。本 skill 关注的核心问题是: 被审计项目的代码如何触发这些已知的框架缺陷模式。

## 深入参考

- 5 大框架/组件漏洞模式详解 → [references/framework-vulns.md](references/framework-vulns.md)

---

## 5 大框架/组件速查表

| 框架/组件 | 核心风险 | 首要搜索关键字 | 典型严重度 |
|-----------|---------|---------------|-----------|
| Spring 全家桶 | SpEL 注入 / Actuator 暴露 / Mass Assignment | `@Value` `SpelExpression` `Actuator` `management.endpoints` | 高-严重 |
| Struts2 | OGNL 注入 / Content-Type 解析 | `struts.xml` `ActionSupport` `ValueStack` `ognl` | 严重 |
| Shiro | RememberMe 反序列化 / URI 绕过 | `setCipherKey` `rememberMe` `ShiroFilterChain` | 严重 |
| FastJSON/Jackson/Gson | 反序列化 autotype / polymorphic | `JSON.parseObject` `JSON.parse` `enableDefaultTyping` `@JsonTypeInfo` | 严重 |
| MyBatis | `${}` SQL 拼接注入 | `${` 在 Mapper XML / `@Select` `@Update` 注解 | 高 |

### Spring 全家桶审计要点

- **Spring MVC 参数绑定（Mass Assignment）**: `@ModelAttribute` 会自动将请求参数绑定到对象字段。若实体类含 `role`/`isAdmin`/`price` 等敏感字段且未使用 `@InitBinder` + `WebDataBinder.setAllowedFields()` 做白名单，攻击者可通过添加额外参数覆写敏感属性
- **Spring Boot Actuator**: 检查 `management.endpoints.web.exposure.include` 配置。高危端点: `/actuator/env`（泄露配置 + restart RCE）、`/actuator/jolokia`（JNDI 注入）、`/actuator/heapdump`（堆转储提取密钥/密码）、`/actuator/gateway/routes`（Gateway 路由注入）
- **SpEL 注入**: 5 种常见注入点, `@Value("#{externInput}")`、`@Cacheable(key="#root.args[0]")` 拼接用户输入、`@PreAuthorize` / `@PostAuthorize` 表达式拼接、`ExpressionParser.parseExpression()` 直接解析外部输入、Spring Data `@Query` 中的 SpEL `?#{...}`
- **Spring Cloud Gateway**: CVE-2022-22947 类型漏洞，路由 Predicate/Filter 配置中嵌入 SpEL 表达式，通过 Actuator `/gateway/routes` 动态注册恶意路由
- **Spring Security 配置陷阱**: `antMatchers` 顺序错误（宽松规则在前覆盖严格规则）、`.permitAll()` 范围过大、路径匹配与 Servlet 路径不一致（如尾部斜杠 `/admin` vs `/admin/`）

### Struts2 审计要点

The rest: https://github.com/wgpsec/AboutSecurity/blob/HEAD/skills/code-audit/java/java-framework-audit/SKILL.md
