PT-2026-88811 · Ocaml+1 · Mirage-Crypto
CVE-2026-87732
·
Published
2026-07-27
·
Updated
2026-09-09
CVSS v3.1
6.2
Medium
| Vector | AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
On the generic GCM path,
AES.GCM.authenticate decrypt into (as well as Chacha20.authenticate decrypt into and AES.CCM16.authenticate decrypt into) writes the decrypted plaintext into the caller's destination buffer and only then compares the tag. On a forged tag the function returns false, but the destination buffer already holds the full plaintext. AEAD decryption is meant to be all-or-nothing: no plaintext should be released until the tag verifies. This is a release of unverified plaintext, and a caller that reads the buffer without first checking the return value sees forged-but-decrypted data. RustCrypto's aes-gcm fixed the same defect in CVE-2023-42811 (rated medium) by re-encrypting the buffer on tag failure.Solution
The tag is validated first, and only if the tag is valid, the decryption into the provided buffer is done. In the CCM code, the tag is computed over the plaintext - if the tag validation fails, the provided buffer is zeroed.
Reproduction
OCaml
module GCM = Mirage crypto.AES.GCM
let () =
let key = GCM.of secret (String.make 32 'x00') in
let nonce = String.make 12 'x00' in
let secret = "let password = 42" in
let len = String.length secret in
let blob = GCM.authenticate encrypt ~key ~nonce secret in
(* flip one bit of the 16-byte tag (at offset len); the ciphertext is untouched *)
let forged = Bytes.of string blob in
Bytes.set forged len (Char.chr (Char.code (Bytes.get forged len) lxor 1));
let forged = Bytes.unsafe to string forged in
let dst = Bytes.make len 'x00' in
let verified =
GCM.authenticate decrypt into ~key ~nonce forged ~src off:0 ~tag off:len dst
~dst off:0 len
in
Printf.printf "tag verified: %b (the message is rejected as forged)
" verified;
Printf.printf "secret left in the output buffer: %S
" (Bytes.to string dst)Timeline
- June 25th 2026: report to ocaml/security-advisories
- June 29th: acknowledgement of issue with several questions for the reporter
- July 6th: answers from reporter, including a patch
- July 27th: release of mirage-crypto 2.2.0 and security advisory
Exploit
Fix
Improper Verification of Cryptographic Signature
Found an issue in the description? Have something to add? Feel free to write us 👾
Weakness Enumeration
Related Identifiers
Affected Products
Mirage-Crypto