CWE-347Identity & accessSeverity · Critical

Tokens accepted without a valid signature

The API trusts a token's claims before checking its signature, or accepts unsigned tokens. Anyone can then write their own token and sign in as any user.

At a glance

Controls
CWE-347 · A02:2021 Cryptographic Failures
Typical severityCritical
ReferenceCWE-347
OWASP Top 10A02: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.

  1. 01Read the code to find where tokens are parsed and which key and algorithm are expected.
  2. 02Sign in as a test user, take that token, and change a claim to point at a second test user.
  3. 03Send the altered token unsigned and with a wrong signature, and record whether the API accepts either.
The rule, in plain English

A token must be rejected unless its signature verifies with the expected key and algorithm.

Executable check

as 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

  1. 01

    Verify the signature before reading any claim, using a maintained library's verify function.

  2. 02

    Fix the allowed algorithm and key on the server, and ignore what the token header asks for.

  3. 03

    Reject tokens with alg none or with an unknown key ID.

  4. 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? →

ExploitOps discovery call

Understand where your security loop breaks.

A call with a MATT co-founder to understand your product and whether an ExploitOps Review is worth doing. If there is a real need, we scope one with the research team.

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02