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
class AeadBox {
AeadBox(byte[] key, int tagBytes) {
// tagBytes flows straight in, no floor
this.params = new AeadParams(key, tagBytes * 8);
}
}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);
}
}Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
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
- Enforce a 128-bit minimum GCM tag at construction and reject anything shorter.
- Grep for AEAD or GCM setup that reads the tag length from a variable or config.
- Give omitted tag lengths a full-size default so a careless caller still gets a strong tag.