
POC لـ CVE-2026-4444 يوضح الالتباس في خوارزمية JWT عبر حقن معرّف مفتاح (kid) غير موثوق، ويتضمن خادم Node.js به ثغرة أمنية ونص برمجي للاستغلال بلغة Python لتزوير الرموز وتصعيد الامتيازات.
// 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'));
تثق خدمة التحقق من JWT بشكل أعمى بحقل kid لتحديد موقع المفتاح العام، مما يسمح للمهاجم بتقديم عنوان URL يشير إلى مفتاحه الخاص. يؤدي ذلك إلى تزوير كامل للتوكن وتصعيد الامتيازات.
kid يتحكم فيه المستخدم دون التحقق من أنه ينتمي إلى مصدر موثوق.node jwt_server.js
python exploit_jwt_kid.py