iamops.dev Search
Argo on X RSS feed
ENEnglish

Knowledge Explainer · 5 min Beginners

You know what a login is, and now you want to read the token your app receives without guessing.

JWT explained: what is inside a token, and why alg none is a trap

A JWT has three parts: a header, a payload of claims and a signature. What each part does, and why a server must pin the algorithm it accepts.

Three actors: an attacker sends a token with alg none and no signature, the API server asks its keys for a check, and then accepts the forged claims as admin.
TL;DRA JavaScript Object Notation (JSON) Web Token is a short signed note…

Your browser signs in to a web app, and the app then calls an API for you. The API needs to know who you are, but it should not ask the login server about every request. The usual answer is a token it can check on its own. If you have not read the access, refresh and ID tokens explainer yet, read it first. This article zooms into one of those tokens.

What a JWT is#

A JSON Web Token, or JWT, in its common signed form is a string with three parts separated by dots. The format is defined in RFC 7519, published by the IETF in 2015.

Anyone who holds the string can read it. The parts are encoded, not hidden. What makes the token trustworthy is the last part, the signature.

Think of a sealed letter from your bank. Anyone can read the letter, but the wax seal proves that the bank wrote it and that nobody changed a word on the way. A JWT works the same way: the content is open, the seal is what counts.

The three parts#

The first part is the header. It says which algorithm made the signature, for example RS256.

The second part is the payload. It holds the claims, which are the statements about the user or the client.

The third part is the signature. It covers the first two parts, so a change to either one breaks it.

Claims: what the payload says#

Claims are simple key and value pairs. The RFC gives some standard names. The issuer, iss, is the login server that made the token. The subject, sub, is the user or client. The audience, aud, is the API the token is meant for. The expiry, exp, is the time after which the token is no longer valid. Teams add their own claims too, such as a role or a tenant name.

Take a payroll API. A token says the subject is an employee, the audience is the payroll API and the role is viewer. The payroll API should accept it only when the audience matches its own name. A token issued for the expense app should not open the payroll API, even when the same login server signed it correctly.

The signature: who made this#

The login server usually signs the token with a private key that only it holds. The API checks the signature with the matching public key, which the login server publishes. If one character in the header or payload changes, the check fails.

The signature proves who signed the token. It does not prove that the token is still valid, so the expiry claim still matters. A correct signature on an expired token is still a dead token.

The trap: alg none#

The header names the algorithm, and the specification also defines a value called none. It means the token carries no signature. Some libraries accepted that value without a key, and an attacker could write any claims they wanted into a token with no seal at all.

This is not old history. The GitHub Advisory Database published GHSA-7wc2-qxgw-g8gg, a flaw in the Python library Authlib, under the identifier CVE-2026-28802. The advisory says that after an upgrade from version 1.5.2 to 1.6.0, and again with the latest 1.6.5, a forged token with alg none and an empty signature passed the verification step. The same test failed on 1.5.2.

Three actors: an attacker sends a token with alg none and no signature, the API server asks its keys for a check, and then accepts the forged claims as admin.
No seal, no check. A library that accepts alg none skips the one step that matters, and the forged role goes through.

The advisory lists versions 1.6.5 and 1.6.6 as affected and 1.6.7 as the fix.

The lesson is about defaults. A library’s default settings are part of your security. An upgrade can change what it accepts, so test the refusals again after every upgrade.

What to check#

Before an API trusts a JWT, it should do four things.

  • Accept only the algorithms it expects, such as RS256, and reject none.
  • Verify the signature with keys from an issuer it trusts.
  • Check the issuer and the audience, so a token for another API fails.
  • Check the expiry and refuse old tokens.

The JWT Best Current Practices, RFC 8725, go through these checks in more detail. Read it once, and then test your own API with a token you forge yourself.

Where to go next#

Sources#

Discuss this on X or LinkedIn

Follow on X

New posts by email

One email a week with new posts and labs. Unsubscribe anytime.

Your address is stored with Kit, which sends the emails. Details

Related research and labs

Type to search every page. Use the arrow keys to move through the results.

    Open the full search page