DEV Community

Cover image for What verifying a JWT must include
Georgi Kalchev
Georgi Kalchev

Posted on Originally published at aiskills402.com

What verifying a JWT must include

Checking a token signature is not enough. Which algorithm, issuer, audience, expiry and key id your code insists on decides whether a forged token gets in.

A JSON Web Token is three pieces of base64 text, and the middle one, the payload, is readable by anyone. JWT verification is the work that turns it from a claim into a fact, and it has more parts than "the signature matched". Your code has to decide which algorithm it accepts before it looks at the token, confirm who issued it, confirm it was meant for this service, and refuse it once it has expired. When any one of those is left to the token itself, an attacker writes the answer. This guide walks through each step, names the mistake that usually sits there, and finishes with a test that is able to fail.

Read the full report on AISkills402: https://aiskills402.com/blog/jwt-verification-mistakes?utm_source=devto&utm_medium=social

Top comments (0)