IntentiAI

Sign-in token decoded but never verified

jwt.decode, jwtDecode or a hand-made base64 decode whose user id decides access, with no verify in the same function.

Check jwt-decode-authShip Check

Why it matters

Decoding a token only reads what it says; verifying checks who signed it. The two calls sit side by side in every JWT library, and decode needs no secret, so an agent short on configuration picks it and the sign-in flow appears to work.

Anyone can then write a token with any user id in it. The app reads the id and treats the caller as that user, admin included.

Example

 export async function requireUser(req: Request) {
   const token = req.headers.get("authorization")?.slice(7) ?? "";
+  const claims = jwt.decode(token) as { sub: string };
+  return { id: claims.sub };
 }

What it detects

  • jwt.decode, jwtDecode, jwt_decode, decodeJwt or a token's middle part base64-decoded by hand, on an added line, where the same function reads the result's sub, id, userId, email or role and calls no verify function (jwt.verify, jwtVerify, verifyIdToken, the auth provider's getUser).
  • Python: jwt.decode with signature verification switched off, and get_unverified_claims.

What to do when it fires

Verify the token with the signing secret or public key (jwt.verify, jose's jwtVerify, or the auth provider's own check), reject it when that fails, and only then read the user id.

Sign-in token decoded but never verified: AI code review check | IntentiAI