Menu

Bug Bounty Tip: Exploiting JWT kid Header Injection for Authentication Bypass
📰

Bug Bounty Tip: Exploiting JWT kid Header Injection for Authentication Bypass

DEV Community: infosec·Zahidul Islam·7 days ago
#6WvB3I1h
#devtoinfosec#devto#dev#server#enter
Reading 0:00
15s threshold

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…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.