Skip to content
ScanAnt

What is a JWT (JSON Web Token)?

A JSON Web Token (JWT) is a compact, signed string that carries claims such as a user ID and role, which a server can verify without a database lookup. It is signed, not encrypted: anyone who holds the token can read its contents.

How it works

A JWT has three base64 parts: a header that names the signing algorithm, a payload with claims, and a signature made with a secret or a private key. The server recomputes the signature to be sure the payload was not changed. Problems appear when the server accepts the algorithm named in the token (including "none"), when the signing secret is short or guessable, when tokens never expire, or when sensitive data is put in the payload thinking it is hidden. A leaked token can be replayed until it expires.

// header.payload.signature
// payload (readable by anyone):
{ "sub": "user_123", "role": "authenticated", "exp": 1767225600 }

// Verify with a fixed algorithm
jwt.verify(token, secret, { algorithms: ["HS256"] });

How to tell if your site is affected

  • The server verifies tokens without fixing the allowed algorithm, or accepts alg "none".
  • The HS256 signing secret is short, a dictionary word or a default value from a tutorial.
  • Tokens have no exp claim, or live for months.
  • The payload contains passwords, personal data or internal flags the client can edit and the server trusts.
  • Tokens are stored in localStorage, where any XSS can read them.

How to fix it

  1. Verify the signature on every request with a pinned algorithm and reject "none".

  2. Use a long random secret (32+ bytes) or asymmetric keys, and keep them server-side only. Rotate them if exposed.

  3. Set short expiry (minutes) for access tokens with refresh tokens you can revoke.

  4. Never put secrets in the payload and never trust role claims the user can influence without server verification.

  5. Prefer HttpOnly, Secure, SameSite cookies for browser sessions. For Supabase, never expose the service_role JWT, which is a token with full access.

How ScanAnt checks for it

Quick scanDeep scan

The free quick scan decodes JWT-shaped strings found in your public JavaScript and reports a service_role token, which gives full database access. The token is shown masked and never used. In the deep scan, a verified owner gets an offline check for a weak signing secret using a short list of common values, with no request made to your server. Token handling inside your server code is not tested.

Questions

Is a JWT encrypted?

No. It is signed, so it cannot be changed unnoticed, but the payload is only base64 encoded. Treat the contents as public.

Is the Supabase anon JWT a secret?

No. The anon key is a JWT with the anon role and is meant to be public. The service_role JWT is a secret.

Where should I store a JWT in the browser?

An HttpOnly cookie is safest against XSS theft. localStorage is convenient but readable by any injected script.

How do I log a user out with JWT?

Short expiry plus revocable refresh tokens, or a server-side block list. A stateless token cannot be recalled before it expires.

See if your site is affected

Free for any public site, no signup. Need the verified or deep scan? Choose the level on the scan page.

Choose a scan level →