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

A short GCM tag is a forgeable GCM tag

The cipher wrapper took the authentication tag length as a plain constructor argument with no floor. Pass a small value and integrity gets cheap to forge.

the caller sets atag lengththe value becomesthe GCM MAC sizeno minimum isenforceda short tag isacceptedforgery oddsclimbATTACKER INPUTIMPACToutput is predictable
Attack path · the caller sets a tag length → the value becomes the GCM MAC size → no minimum is enforced → a short tag is accepted → forgery odds climb

The cipher wrapper took the authentication tag length as a plain constructor argument with no floor. Pass a small value and integrity gets cheap to forge.

What goes wrong

The tag on an AES-GCM ciphertext is what stops an attacker editing the bytes and having you accept the result. Its strength is its length. A 128-bit tag means a blind forgery attempt succeeds about once in 2^128. A 32-bit tag succeeds about once in four billion, which is well within reach of an online endpoint that lets you retry.

This constructor took the tag length as an integer and passed it into the AEAD parameters with no minimum. A caller that picks a small size gets a cipher that still encrypts correctly and still round-trips in tests, while quietly offering almost no integrity. It is a Medium, so keep it in proportion: nobody reads your plaintext from this alone. What you lose is the guarantee that a message came through unmodified, which is most of the reason to use GCM in the first place.

The pattern

Vulnerable
class AeadBox {
  AeadBox(byte[] key, int tagBytes) {
    // tagBytes flows straight in, no floor
    this.params = new AeadParams(key, tagBytes * 8);
  }
}
Hardened
class AeadBox {
  AeadBox(byte[] key, int tagBytes) {
    if (tagBytes < 16)
      throw new IllegalArgumentException("tag must be >= 128 bits");
    this.params = new AeadParams(key, tagBytes * 8);
  }
}
How the pipeline adjudicated itPROVEN
ABCDEFGH

Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.

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

Why it matters to you

If any caller can dial the tag down, your authenticated encryption is only as strong as the least careful call site. In practice that means some config default or a copied constructor sets four or eight bytes, and it stays that way until someone forges a message and you find out.

Make the minimum a property of the type, not a decision handed to the caller. A floor of 128 bits and a safe default cost nothing and close the door.

Check your own code