The encryptor took the nonce from its caller and used it as-is, twice, with no uniqueness or randomness check. For AEAD, a repeated nonce is a broken cipher.
What goes wrong
AES-GCM and the other common AEAD modes have one rule you cannot bend. Never use the same nonce twice under the same key. Break it once and the keystream repeats, so XOR the two ciphertexts and the plaintext leaks. The same slip can expose the authentication key, which lets an attacker forge messages that verify.
This code took the nonce straight from the caller with no check on length, uniqueness, or randomness, then handed that same value to both cipher instances. If the two instances share a key, which a related flaw here allows, the reuse is immediate. Even when they don't, you are one careless caller away from repeating a nonce across encryptions. Nonce generation is the library's job. Produce it inside the cipher layer, from a counter or a CSPRNG, and don't accept it as input for a fresh encryption.
The pattern
Package seal(byte[] key1, byte[] key2, byte[] nonce, byte[] msg) {
// nonce comes straight from the caller, unchecked
var boxA = new Aead(key1, nonce);
var boxB = new Aead(key2, nonce); // same nonce, two boxes
return new Package(boxA.encrypt(msg),
boxB.encrypt(msg));
}Package seal(byte[] key1, byte[] key2, byte[] msg) {
byte[] n1 = random(12); // fresh and unique per encryption
byte[] n2 = random(12);
var boxA = new Aead(key1, n1);
var boxB = new Aead(key2, n2);
return new Package(boxA.encrypt(msg), boxB.encrypt(msg));
}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.
Why it matters to you
Nonce reuse is one of the few crypto bugs that is both easy to trigger and total in its effect. An attacker who can replay a nonce, or who just watches two messages that shared one, reads your traffic and forges new messages under your key.
Accepting the nonce from outside makes the bad case something an attacker can choose, not something you accidentally hit. Own the nonce inside the cipher and the whole class of bug goes away.
Check your own code
- Generate AEAD nonces inside the cipher layer instead of accepting them from callers.
- Never reuse one nonce across two encryptions, even under different keys.
- If a nonce truly must come from outside, enforce its length and track used values to reject repeats.