At a glance
- Controls
- CWE-347 · A02:2021 Cryptographic Failures
What it is
A signed token carries claims such as user ID and role, and the signature proves the issuer wrote them. Some APIs decode the claims and use them without verifying the signature. Others accept the "none" algorithm, or let the token choose which algorithm and key to use.
An attacker takes their own token, edits the user ID or role, and sends it back unsigned or re-signed with a key they control. If the API accepts it, they act as any user. AI-assisted attackers try the known forged-token variants in seconds, so a weak check is found fast.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Custom authentication middleware that decodes tokens by hand
- Services that call a decode function where a verify function was needed
- Token libraries configured to accept any algorithm the header names
- Internal or edge services that assume the gateway already checked the token
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Read the code to find where tokens are parsed and which key and algorithm are expected.
- 02Sign in as a test user, take that token, and change a claim to point at a second test user.
- 03Send the altered token unsigned and with a wrong signature, and record whether the API accepts either.
A token must be rejected unless its signature verifies with the expected key and algorithm.
Executable checkas user A: send A's token with sub changed to B and the signature removed expect: 401 send a token with alg set to none, and one signed with a different key expect: 401 for each
Every rule MATT holds →What the fix looks like
- 01
Verify the signature before reading any claim, using a maintained library's verify function.
- 02
Fix the allowed algorithm and key on the server, and ignore what the token header asks for.
- 03
Reject tokens with alg none or with an unknown key ID.
- 04
Verify tokens in every service that uses them, including internal ones.
A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →