
CVE-2026-21003에 대한 개념 증명 익스플로잇으로, `kid` 헤더를 생략하고 'none' 알고리즘을 사용하여 JWT 인증 우회를 통해 사용자를 가장하는 방법을 시연합니다.
// jwt_verify_server.js - Vulnerable JWT verification
const jwt = require('jsonwebtoken');
const express = require('express');
const app = express();
app.use(express.json());
const publicKey = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1SU1LfVLPHCYZM5rPY4...
-----END PUBLIC KEY-----`;
app.post('/verify', (req, res) => {
const token = req.body.token;
// Vulnerability: if no algorithm specified, defaults to HS256? Actually, jsonwebtoken can be tricked.
// We simulate a custom verifier that accepts "none" if kid is missing.
const decoded = jwt.decode(token, { complete: true });
if (!decoded.header.alg || decoded.header.alg === 'none') {
// Accept token without signature
res.json({ status: 'authenticated', user: decoded.payload.sub });
} else {
jwt.verify(token, publicKey, { algorithms: ['RS256'] }, (err, payload) => {
if (err) res.status(401).send('Invalid');
else res.json({ status: 'authenticated', user: payload.sub });
});
}
});
app.listen(3000);
사용자 정의 JWT 검증기가 서명 알고리즘의 존재를 제대로 강제하지 않습니다. 토큰의 헤더가 alg 매개변수를 생략하거나 명시적으로 none으로 설정하면, 서버는 서명을 검증하지 않고 토큰을 수락하므로 권한 상승이 가능해집니다.
npm install express jsonwebtoken
node jwt_verify_server.js
pip install pyjwt requests
python exploit_jwt_none.py
응답에는 admin으로 인증된(authenticated) 상태가 표시됩니다.