Every internal service trusts tokens checked by one small JWT verifier. It accepts alg "none", lets the header pick any algorithm, never checks expiry, audience or issuer, and resolves the key id as a file path. Make decode() reject everything it should without breaking valid tokens.
This is the practice version. Assessments always use a variant you have never seen.
A bug-bounty report says a forged token reached the billing API last night. authn/jwt.py:decode(token, keys, audience=…, issuer=…) is the only thing between the
internet and every internal API. Keys live in a directory, one file per key id (keys/<kid>.key).
Make decode return the claims of a valid token and raise InvalidToken (from authn/errors.py) for
everything else:
HS256 (including none), unknown or unsafe key ids, malformed tokens;exp is required), tokens before nbf, tokens issued in the future; the default leeway
is 30 seconds;aud (string or list) that does not include audience, or an iss other than issuer.No other exception type may escape decode. Read THREAT_MODEL.md first.
| Review an AI-Written Refund PR Before It MergesBackend & APIsTiers: Junior, Mid-levelEditorial | Medium | Code review | 45 min | Calibrating |