InBrott
target://jwt-alg-none
mediumOPEN

Trusting Token Verifier

jwtbroken-authcryptography

// Scenario

A microservice verifies compact HS256 JWT tokens using verify_jwt(token, secret, now_ts) / verifyJwt(token, secret, nowTs).

// The Vulnerability

  1. It trusts the token header's alg blindly: if alg is "none" (or "None"), it skips signature verification completely!
  2. It ignores token expiration (exp).
  3. It compares signatures with == / === instead of a constant-time comparison.

// Your Task

Harden JWT verification:

  • Strictly require typ (if present) and alg === "HS256" (reject none, RS256, etc.).
  • Require a non-empty signature and verify HMAC-SHA256 using constant-time comparison (hmac.compare_digest / crypto.timingSafeEqual).
  • Require numeric exp and reject expired tokens (now_ts >= exp).
  • Return the decoded payload dict/object on success, or None / null on any failure.

Sample Sanity Checks (1)

  • Valid HS256 token passes
    Properly signed unexpired HS256 token returns payload
Hints (0/3)
initializing editor...

[idle] Press RUN to execute visible sample checks, or SUBMIT to run hidden exploit & functionality suites.