George0Papasotiriou/CVE-2026-4444-JWT-Algorithm-Confusion-via-kid-Injection

GitHub: George0Papasotiriou/CVE-2026-4444-JWT-Algorithm-Confusion-via-kid-Injection

该项目演示了 CVE-2026-4444 漏洞,即 JWT 验证服务因未校验 kid 头部来源而导致 token 伪造和权限提升。

Stars: 0 | Forks: 0

## CVE-2026-4444 – 通过 kid 注入的 JWT 算法混淆 ### **程序代码 (Node.js 服务器 + Python exploit)** ``` // jwt_server.js - Vulnerable JWT verification server const express = require('express'); const jwt = require('jsonwebtoken'); const jwksClient = require('jwks-rsa'); const axios = require('axios'); const app = express(); app.use(express.json()); // Normally fetches public key from a JWKS endpoint, but vulnerable kid handling async function getPublicKey(kid) { // Attacker can inject a kid that points to their own URL if (kid.startsWith('http://') || kid.startsWith('https://')) { // Fetch the key from attacker-controlled URL (INSECURE!) const response = await axios.get(kid); return response.data.publicKey; // expects PEM } // Otherwise use local JWKS (simulated) return `-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1SU1LfVLPHCYZM5rPY4 ... -----END PUBLIC KEY-----`; } app.post('/api/verify', async (req, res) => { const token = req.body.token; const decoded = jwt.decode(token, { complete: true }); const kid = decoded.header.kid; try { const publicKey = await getPublicKey(kid); const payload = jwt.verify(token, publicKey, { algorithms: ['RS256','HS256'] }); res.json({ status: 'authenticated', user: payload.sub }); } catch (e) { res.status(401).json({ error: e.message }); } }); app.listen(3000, () => console.log('JWT server on :3000')); ``` # CVE-2026-4444 – 通过 kid 注入的 JWT 算法混淆 ![严重程度:严重](https://img.shields.io/badge/severity-critical-red) ## 概述 JWT 验证服务盲目信任 `kid` 头部来定位公钥,允许攻击者提供一个指向其自身密钥的 URL。这会导致完全的 token 伪造和权限提升。 ## 漏洞详情 - **类型:** JWT 算法混淆 / SSRF - **影响:** 未经授权的访问,管理员冒充。 - **根本原因:** 服务器从用户控制的 `kid` URI 获取公钥,而没有验证其是否属于受信任的源。 ## Exploit 演示 1. 启动存在漏洞的服务器: node jwt_server.js 2. 运行 exploit(它也会启动一个伪造的密钥服务器): python exploit_jwt_kid.py
标签:CISA项目, GNU通用公共许可证, JWT安全, MITM代理, Node.js, Python, 安全漏洞, 无后门, 逆向工具