JSON Web Tokens (JWTs) are everywhere, but implementation flaws in key retrieval mechanisms continue to yield critical authentication bypasses in bug bounty programs.
🎯 What to Look For
When decoding a JWT, inspect the header for a kid (Key ID) parameter:
{ "alg" : "HS256" , "kid" : "key1" }
Enter fullscreen mode
Exit fullscreen mode
The kid header is designed to specify which key the backend server should use to verify the token signature. However, if the server fetches or queries this key without strict sanitization, serious vulnerability patterns arise.
🧪 Attack Vectors to Test
Path Traversal / Null Key Bypass:
"kid" : "../../../../dev/null"
Enter fullscreen mode
Exit fullscreen mode
Mechanism: If the server reads the key file from the filesystem path specified by kid , pointing it to /dev/null causes the server to verify the signature using an empty string ( "" ) as the HMAC secret key.
SQL Injection via Key Retrieval:
"kid" : "key1' UNION SELECT 'attacker_secret'-- -"
Enter fullscreen…