Menu

🔑 JWT Verification Bugs: Pin the Algorithm, Then Prove the Fix
📰

🔑 JWT Verification Bugs: Pin the Algorithm, Then Prove the Fix

DEV Community: appsec·Krishna Kumar·10 days ago
#S9l6RuUy
#devtoappsec#devto#dev#token#hs256
Reading 0:00
15s threshold

Most JWT vulnerabilities aren't broken cryptography. HS256 and RS256 are fine. Where things go wrong is the code that's supposed to check the token: it decodes it but never verifies it, lets the token pick its own algorithm, or checks the signature and then ignores who the token was issued to.

This is a fix guide for developers. We'll go through the verification mistakes that keep showing up, how to search your own code for them, how to configure PyJWT, jsonwebtoken and jose so the library enforces the rules for you, and a small test suite that proves your verifier rejects what it should. That last part matters most. "We use a JWT library" doesn't tell you your tokens are safe. A failing forged token in CI does.

Only run these tests against code you own or are authorized to test.

What "verifying a JWT" actually means

A signed JWT is three base64url parts: header.payload.signature .…

Continue reading — create a free account

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