JWTs decoded but never verified
Last updated November 17, 2026
Steps
- Search your code for jwt.decode(, decodeJwt(, jwt_decode(, atob( on token parts, and Buffer.from(token.split('.')[1]. Any of these feeding an auth decision is a red flag.
- Replace them with a verifying call: jwt.verify() in jsonwebtoken, jwtVerify() in jose, or your auth provider's server helper.
- Pin the accepted algorithm list (for example algorithms: ['RS256'] or ['HS256']) so a token can't choose none or switch algorithms.
- Check exp, and check iss and aud match your app, as OWASP and RFC 8725 recommend.
- On Supabase, use supabase.auth.getClaims() (or getUser()) to protect server routes and pages, not getSession().
- For HMAC-signed tokens, use a long random secret kept server-side, and rotate it if it was ever in client code or a repo.
- Test it: change one character in a valid token's payload and confirm every protected route returns 401.
Why it matters
OWASP's JSON Web Token Cheat Sheet warns about tokens using the none algorithm, algorithm confusion and missing signature checks, and recommends validating issuer, audience and expiry. RFC 8725 (JWT Best Current Practices) says libraries must let callers specify allowed algorithms and must not use any others. MITRE classifies the underlying flaw as CWE-347, Improper Verification of Cryptographic Signature. A JWT's payload is only base64url-encoded, so trusting a decoded but unverified token lets anyone sign themselves in as any user.
Sources
OWASP Cheat Sheet Series: JSON Web Token Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_Cheat_Sheet.html
IETF RFC 8725: JSON Web Token Best Current Practices — https://www.rfc-editor.org/rfc/rfc8725
auth0/node-jsonwebtoken README (jwt.decode does not verify the signature) — https://github.com/auth0/node-jsonwebtoken
panva/jose: decodeJwt (decodes without validating) — https://github.com/panva/jose/blob/main/docs/util/decode_jwt/functions/decodeJwt.md
Supabase: Setting up Server-Side Auth for Next.js (use getClaims, never trust getSession in server code) — https://supabase.com/docs/guides/auth/server-side/nextjs
MITRE CWE-347: Improper Verification of Cryptographic Signature — https://cwe.mitre.org/data/definitions/347.html
Related patterns
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.