Blog / A02:2021 Cryptographic Failures
A02:2021 · Cryptographic Failures

An open alg field is how JWTs get forged

A signing endpoint let the request choose the JWS algorithm. Without a strict allowlist, that opens the door to alg none and public-key confusion attacks.

the request namesthe JWS algorithmthe value isforwarded to…noapproved-algorit…the token issigned with…an attacker mintstokens you…ATTACKER INPUTIMPACTcheck absent
Attack path · the request names the JWS algorithm → the value is forwarded to the signer → no approved-algorithm check runs → the token is signed with a weak or confused algorithm → an attacker mints tokens you will accept

A signing endpoint let the request choose the JWS algorithm. Without a strict allowlist, that opens the door to alg none and public-key confusion attacks.

What goes wrong

JWS has carried the same wound for years: trusting the alg field. This endpoint took the algorithm from the request and forwarded it to the signer, with no visible allowlist rejecting the dangerous values.

That brings back the classic failures. A caller asks for alg none and gets an unsigned token that some verifiers still wave through. A caller asks for HMAC while the service is built around RSA, and your public key becomes the shared HMAC secret, so anyone holding that public key can sign valid tokens. Or a caller simply selects a deprecated variant that is cheaper to attack. The set of algorithms your system accepts is a server decision. Write it down as a fixed list and refuse everything outside it, on the signing side and the verifying side both.

The pattern

Vulnerable
String issue(Claims claims, String alg) {
  var header = new Header(alg);   // alg comes from the request
  var signer = signerFor(alg);    // "none", "HS256", "RS256"...
  return header + "." + encode(claims)
       + "." + signer.sign(header, claims);
}
Hardened
private static final Set<String> ALLOWED = Set.of("RS256", "ES256");
String issue(Claims claims) {
  String alg = "ES256";           // fixed by policy
  var signer = signerFor(alg);
  return sign(new Header(alg), claims, signer);
}
// the verifier also pins ALLOWED and rejects "none" outright
How the pipeline adjudicated itHELD
ABCDEFGH

Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

If tokens carry identity in your system, an attacker who controls the algorithm can forge identity. alg none and key-confusion attacks turn signed by us into signed by anyone, and every service downstream that trusts these tokens inherits the hole.

This one deserves urgency. Pin the algorithm on both sides, refuse alg none, and verify against the algorithm you expect rather than the one the token claims for itself.

Check your own code