Identity and access Leaked tokens 4 min read

What happens when a JWT is stolen?

Priya’s valid JWT ends up in a debug log, and someone else sends it to the orders API. How would the API know it isn’t Priya?

  1. The API checks the token, not who holds it

    A JWT is a bearer token: whoever presents it gets what it allows. The API checks the signature and the claims (issuer, audience, expiry), and all of them are still perfectly valid.

    Nothing in the token says who is sending it. So the API accepts it, and acts as Priya until the token expires.

    Someone else sends Priya’s leaked token to the orders API. The API checks the signature, issuer, audience and expiry, all pass, and it returns Priya’s orders.

    Every check passes. That’s the whole problem.

    In short A valid signature proves the token is genuine, not who’s holding it.

  2. What lets the API refuse it

    Expiry: a token that expired two minutes ago is refused, so short lifetimes shrink the window. Audience: a token made for admin-api is refused by orders-api, so tight audiences limit where a leak works.

    Revocation: if the API checks a list of revoked token IDs (jti), a token from a session Priya ended can be refused before it expires.

    In short Short expiry, tight audiences and revocation are what stop a leaked token.

  3. Make it leak less, and matter less

    Keep tokens out of logs and URLs. Tie tokens to a key only the real client holds, so a copied token is useless without it.

    A stronger signing algorithm doesn’t help: the signature was never the weak spot. Neither does encoding the token twice; anyone can undo it.

    In short You can’t make a leaked token fake. You can make it short-lived and useless elsewhere.

What signing out doesn’t do

Priya clicks “Sign out of all devices”. If the API keeps no revocation list, her leaked token keeps working for its remaining 50 minutes. Plain JWTs are checked on their own, with no lookup, so the API can’t know.

That’s why access tokens should be short-lived, with longer sessions handled by refresh tokens the server can revoke.

Keep this

A leaked JWT works until it expires. Keep tokens short-lived, out of logs, and revocable.

The signature proves the token is genuine, not that the person presenting it is Priya. Limit the damage with short expiry, revocation and careful storage.
Bearer
Whoever presents it is treated as the user.
Expiry
Short lifetimes shrink the window.
Revocation
A list of revoked token IDs lets the API refuse early.
Storage
Keep tokens out of logs, URLs and page scripts.

Questions worth carrying

How should a browser app hold its tokens?

Ideally where page scripts can’t read them. Many teams hold tokens on the server and give the browser an HttpOnly session cookie instead.

What are refresh tokens for?

They let short-lived access tokens be renewed without signing in again. The server can revoke a refresh token, which ends the chain.

Sources

Last reviewed 17 November 2026.