OSEC-2026-12 (CVE-2026-87732)

Vulnerability from osv_ocaml – Published: 2026-07-27 19:00 – Updated: 2026-09-10 09:45 – Source website
VLAI
Summary
AEAD `decrypt_into` functions writes plaintext before checking the tag
Details

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

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)\n" verified;
  Printf.printf "secret left in the output buffer: %S\n" (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

{
  "affected": [
    {
      "ecosystem_specific": {
        "affected_bindings": [
          "Mirage_crypto.AES.CCM16.authenticate_decrypt_into",
          "Mirage_crypto.AES.CCM16.unsafe_authenticate_decrypt_into",
          "Mirage_crypto.Chacha20.authenticate_decrypt_into",
          "Mirage_crypto.Chacha20.unsafe_authenticate_decrypt_into",
          "Mirage_crypto.AES.GCM.authenticate_decrypt_into",
          "Mirage_crypto.AES.GCM.unsafe_authenticate_decrypt_into"
        ],
        "opam_constraint": "mirage-crypto {\u003c \"2.2.0\"}"
      },
      "package": {
        "ecosystem": "opam",
        "name": "mirage-crypto",
        "purl": "pkg:opam/mirage-crypto"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "2.2.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ],
      "versions": [
        "0.6.0",
        "0.6.1",
        "0.6.2",
        "0.7.0",
        "0.8.0",
        "0.8.1",
        "0.8.2",
        "0.8.3",
        "0.8.4",
        "0.8.5",
        "0.8.6",
        "0.8.7",
        "0.8.8",
        "0.8.9",
        "0.8.10",
        "0.9.0",
        "0.9.1",
        "0.9.2",
        "0.10.0",
        "0.10.1",
        "0.10.2",
        "0.10.3",
        "0.10.4",
        "0.10.5",
        "0.10.6",
        "0.10.7",
        "0.11.0",
        "0.11.1",
        "0.11.2",
        "0.11.3",
        "1.0.0",
        "1.1.0",
        "1.2.0",
        "2.0.0",
        "2.0.1",
        "2.0.2",
        "2.0.3",
        "2.1.0"
      ]
    },
    {
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "25e7570aec91e092b347561c23f84b6ec39e7163"
            }
          ],
          "repo": "https://github.com/mirage/mirage-crypto.git",
          "type": "GIT"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-87732"
  ],
  "credits": [
    {
      "name": "Thomas Gazagnaire",
      "type": "REPORTER"
    },
    {
      "name": "Thomas Gazagnaire",
      "type": "REMEDIATION_DEVELOPER"
    },
    {
      "name": "Hannes Mehnert",
      "type": "REMEDIATION_REVIEWER"
    }
  ],
  "database_specific": {
    "cwe": [
      "CWE-347"
    ],
    "human_link": "https://github.com/ocaml/security-advisories/tree/main/advisories/2026/OSEC-2026-12.md",
    "osv": "https://github.com/ocaml/security-advisories/tree/generated-osv/2026/OSEC-2026-12.json"
  },
  "details": "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\u0027s 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\u0027s aes-gcm fixed the same defect in CVE-2023-42811 (rated medium) by re-encrypting the buffer on tag failure.\n\n## Solution\n\nThe 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.\n\n## Reproduction\n\n```OCaml\nmodule GCM = Mirage_crypto.AES.GCM\n\nlet () =\n  let key = GCM.of_secret (String.make 32 \u0027\\x00\u0027) in\n  let nonce = String.make 12 \u0027\\x00\u0027 in\n  let secret = \"let password = 42\" in\n  let len = String.length secret in\n  let blob = GCM.authenticate_encrypt ~key ~nonce secret in\n  (* flip one bit of the 16-byte tag (at offset len); the ciphertext is untouched *)\n  let forged = Bytes.of_string blob in\n  Bytes.set forged len (Char.chr (Char.code (Bytes.get forged len) lxor 1));\n  let forged = Bytes.unsafe_to_string forged in\n  let dst = Bytes.make len \u0027\\x00\u0027 in\n  let verified =\n    GCM.authenticate_decrypt_into ~key ~nonce forged ~src_off:0 ~tag_off:len dst\n      ~dst_off:0 len\n  in\n  Printf.printf \"tag verified: %b (the message is rejected as forged)\\n\" verified;\n  Printf.printf \"secret left in the output buffer: %S\\n\" (Bytes.to_string dst)\n```\n\n## Timeline\n\n- June 25th 2026: report to ocaml/security-advisories\n- June 29th: acknowledgement of issue with several questions for the reporter\n- July 6th: answers from reporter, including a patch\n- July 27th: release of mirage-crypto 2.2.0 and security advisory",
  "id": "OSEC-2026-12",
  "modified": "2026-09-10T09:45:00Z",
  "published": "2026-07-27T19:00:00Z",
  "references": [],
  "schema_version": "1.7.4",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "AEAD `decrypt_into` functions writes plaintext before checking the tag"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.