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

Callers pick the signing algorithm, so they pick SHA-1

The signing routine took the algorithm name from the caller and passed it into the signer. Nothing stopped a request for a broken hash or a raw, unpadded signature.

the callersupplies…the name ispassed to…a weak mode isaccepteda signature isproduced…the output isforgeable…ATTACKER INPUTIMPACTcheck absent
Attack path · the caller supplies an algorithm name → the name is passed to the signer unchecked → a weak mode is accepted → a signature is produced with broken parameters → the output is forgeable or downgradable

The signing routine took the algorithm name from the caller and passed it into the signer. Nothing stopped a request for a broken hash or a raw, unpadded signature.

What goes wrong

The keys here were meant for modern signatures, RSA with SHA-256 or ECDSA on P-256. But the algorithm name arrived from the caller and went straight into signer construction with no allowlist in the way. If the underlying provider honors arbitrary algorithm strings, a caller asks for a SHA-1 based signature, or a raw signature with no hashing at all, and gets it, produced by your real key.

The key is strong. The algorithm wrapped around it is where the strength actually lives, and that choice was handed to whoever calls the endpoint. Downgrade the hash and you make collisions reachable. Strip the hashing and you open the door to structural forgeries. The algorithm is part of your security policy, so it belongs on the server, pinned, not offered as a request parameter.

The pattern

Vulnerable
byte[] sign(String keyId, String algo, byte[] msg) {
  var key = keys.get(keyId);
  var signer = Signer.getInstance(algo);  // whatever the caller sent
  signer.init(key);
  signer.update(msg);
  return signer.sign();
}
Hardened
byte[] sign(String keyId, byte[] msg) {
  var key = keys.get(keyId);
  // the algorithm is fixed by policy, from the key type
  var signer = Signer.getInstance(policyAlgoFor(key));
  signer.init(key);
  signer.update(msg);
  return signer.sign();
}
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

A signature is a promise your system stands behind. If an attacker can downgrade the algorithm to something forgeable, they can eventually produce signatures you will accept as genuine, using your own key to make them.

Once weak signatures exist in the wild you can no longer tell them from the real ones, and every verifier that trusts this key inherits the problem. Take the choice away from the caller and tie the algorithm to the key.

Check your own code