# Java Auth Config Audit

Java 源码认证与配置安全审计。当在 Java 白盒审计中需要检测认证绕过、权限缺陷或安全配置问题时触发。 覆盖 6 类风险: 认证绕过(Spring...

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

## Install

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

## Description

Java 源码认证与配置安全审计。当在 Java 白盒审计中需要检测认证绕过、权限缺陷或安全配置问题时触发。 覆盖 6 类风险: 认证绕过(Spring Security/Shiro Filter 链 URI 解析差异)、 越权(IDOR/水平越权/垂直越权)、JWT 安全(算法混淆/密钥泄露/Claims 验证)、 加密配置(弱算法/硬编码密钥/不安全随机数)、信息泄露(错误堆栈/Actuator/Debug 模式)、 业务逻辑漏洞(竞争条件/金额篡改/流程绕过)。

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

# Java 认证与配置安全源码审计

Java 后端项目中认证、授权与安全配置是最高频的漏洞产出面。本 skill 提供 6 大类白盒审计的完整检测思路，适用于 Spring Boot/Spring Security、Apache Shiro 及自定义框架。

## 相关 Skill

- `java-framework-audit`, Spring/Struts/MyBatis 框架审计
- `java-injection-audit`, SQL/OGNL/EL 注入审计
- `java-serialization-audit`, 反序列化漏洞审计
- `idor-methodology`, 黑盒 IDOR 测试方法论

## 深入参考

- 6 类漏洞详细模式（危险代码/安全代码/EVID 证据）-> [references/auth-config-patterns.md](references/auth-config-patterns.md)

---

## 6 类风险速查表

| # | 类别 | 关键搜索入口 | 危害等级 |
|---|------|-------------|---------|
| 1 | 认证绕过 | `SecurityConfig`, `ShiroFilterFactory`, `doFilter` | 严重 |
| 2 | 越权 | DAO/Mapper 查询语句, `@PreAuthorize`, Controller 参数 | 高 |
| 3 | JWT 安全 | `Jwts.parser()`, `Algorithm.HMAC`, `SECRET_KEY` | 高 |
| 4 | 加密配置 | `MessageDigest`, `Cipher.getInstance`, `new Random()` | 高 |
| 5 | 信息泄露 | `application.yml` Actuator 配置, `@ExceptionHandler` | 中 |
| 6 | 业务逻辑 | 余额/库存操作, 状态机流转, 支付回调 | 高 |

---

## 1. 认证绕过审计要点

- **Spring Security**: 检查 `FilterChainProxy` 匹配规则，`AntPathRequestMatcher` 与 `MvcRequestMatcher` 差异（尾部斜杠/路径后缀）；`requestMatchers` 顺序, , 宽松规则 `permitAll()` 在前会覆盖后续拦截；`permitAll()` 是否过度开放（如 `/api/**`）
- **Shiro**: URI 解析差异导致绕过, , `/admin/` vs `/admin` vs `/admin/..;/`；CVE-2020-1957 / CVE-2020-11989 / CVE-2020-13933 等 path normalization 系列绕过
- **自定义 Filter**: `doFilter()` 中 early return 导致后续 chain 未执行；白名单正则不严谨（如 `startsWith("/public")` 可被 `/publicevil` 匹配）

## 2. 越权审计要点

- **水平越权**: 接口仅校验登录态未校验资源归属, , DAO 层 `WHERE id = #{orderId}` 缺少 `AND user_id = #{currentUserId}` 条件
- **垂直越权**: Controller/Service 方法缺少角色注解 `@PreAuthorize`/`@RequiresRoles`；枚举值（角色 ID）可猜解
- **IDOR**: 自增 ID 可遍历；UUID 是否真正不可预测；批量接口跳过单条权限检查

## 3. JWT 安全审计要点

- **算法混淆**: `alg: none` 绕过签名验证；RS256 -> HS256 攻击（用公钥作为 HMAC 密钥）
- **密钥硬编码**: 源码中 `SECRET_KEY = "xxx"` 或 `application.yml` 明文配置
- **Claims 校验缺失**: `exp`(过期)/`iss`(签发者)/`aud`(受众) 未验证导致 token 可跨环境复用
- **刷新机制**: `refresh_token` 长期有效且未绑定用户/设备，被盗后可无限刷新

## 4. 加密配置审计要点

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