I found an integer overflow that defeats OCaml's fix for CVE-2026-28364: heap memory disclosure and SIGBUS crashes via Marshal deserialization. PoCs, advisory, and proposed patch — fixed in OCaml 5.5.1 (OSEC-2026-18).
While working on an OCaml project that deserializes data with Marshal, a
malformed input took the process down with a SIGBUS instead of a clean
exception. I pulled the OCaml runtime and started reading
runtime/intern.c. The earlier CVE-2026-28364 fix had added bounds checks
to make Marshal safe against malicious input - but the checks were
bypassable. The length arithmetic still wrapped, and the fix's own
intern_src_end = intern_src + data_len wraps to a pointer before the
buffer, defeating every check the fix added. I wrote minimal PoCs (a heap
info leak and a crash), confirmed the leak under AddressSanitizer,
proposed a fix, and reported it to [email protected]. Xavier Leroy's fix
landed upstream and shipped in OCaml 5.5.1 as OSEC-2026-18.
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:NThe CVE-2026-28364 fix added this bound:
s->intern_src_end = s->intern_src + h.data_len; /* intern.c:1043 */
but h.data_len is fully attacker-controlled. Set it to 2^64 - 16 and:
ofs + h.header_len + h.data_len wraps in the validation
(intern.c:1038), so the check passes.intern_src_end wraps to a location before the buffer.intern_check_read the fix added compares against a negative diff
promoted to a huge uintnat, so they all pass.intern_rec then reads attacker-chosen lengths from past the input: heap
bytes leak into the returned string, or the process dies with SIGBUS.The full write-up is in
advisory/OCAML-MARSHAL-ADVISORY.md.
OSV advisory OSEC-2026-18 -
OCaml 5.5.1 release announcement - discuss.ocaml.org/t/ocaml-5-5-1-released/18510 - lists the fix (PR #15019)
| Path | Description |
|---|---|
advisory/OCAML-MARSHAL-ADVISORY.md | Reporter's original advisory: root cause, exploit path, impact, suggested fix, verification evidence |
advisory/disclosure-timeline.md | Coordinated disclosure timeline and links |
poc/leak.ml | Heap information-disclosure PoC |
poc/crash.ml | Denial-of-service PoC (SIGBUS, exit 138) |
poc/controls.ml | Benign-input controls (must fail cleanly) |
poc/asan-driver.c | C driver used with an ASan-instrumented runtime |
poc/asan-report.txt | AddressSanitizer heap-buffer-overflow report |
patch/intern-overflow-suggested.patch | Reporter's suggested fix (upstream's merged fix is authoritative) |
docs/tools-used.md | Tools and environment used |
The PoCs demonstrate the bug on OCaml <= 5.5.0 (tested on 5.5.0, macOS arm64):
ocamlopt -o leak poc/leak.ml
ocamlopt -o crash poc/crash.ml
ocamlopt -o controls poc/controls.ml
./leak prints a string containing heap bytes read from beyond the
input buffer (contents vary between runs)../crash terminates with SIGBUS (exit 138)../controls must print three OK lines.poc/asan-driver.c requires an OCaml 5.5.0 runtime built from source with
AddressSanitizer (-fsanitize=address); see docs/tools-used.md. It
drives the vulnerable path via caml_input_value_from_block.
On OCaml >= 5.5.1, the crafted inputs fail cleanly with
Failure("Marshal.data_size: object too large to be read back on this platform") (the merged upstream fix, verified against the 5.5.1 tag), and
the controls still pass. The reporter's suggested patch in patch/ raises
Failure("Marshal.data_size: object too large") for the same inputs; the
merged fix is authoritative.
Discovered 2026-08-12, reported 2026-08-15, fixed upstream 2026-09-03,
released in 5.5.1 on 2026-09-05, advisory published 2026-09-10. Details:
advisory/disclosure-timeline.md.
These materials are published for defensive and educational purposes after coordinated disclosure with the OCaml Security Response Team. The PoCs are minimal research artifacts. Do not use them against systems you do not own or have permission to test.
Code (poc/, patch/) is licensed under the MIT License (see LICENSE).
Documentation (README.md, advisory/, docs/) is licensed under
CC BY 4.0.