Back to index

OCaml Marshal

02 / 03
Type
Research
Year
2026
Stack / Focus
Security Research ·OCaml ·C ·Memory Safety ·
OCaml Marshal logo

Overview

I found a security bug in OCaml, helped get it fixed for everyone, and was officially credited by the language’s own team. Left alone, the bug could leak private data or crash programs — now it can’t, for any OCaml user.

The flaw lived in the part of OCaml that loads saved data back into a program (the Marshal deserializer). An earlier security patch had added checks to block malicious input — but a number-overflow in the arithmetic let attackers slip straight past those checks. I demonstrated the problem with small proof-of-concept programs, documented everything, and worked with the OCaml team until the fix shipped in version 5.5.1 as advisory OSEC-2026-18.

  • 6.8

    CVSS 3.1 · Medium

  • 5.5.1

    Fixed in OCaml

  • OSEC-2026-18

    Published advisory

Officially credited

Named as the reporter of OSEC-2026-18 in OCaml’s official security advisory and release notes. The fix was written by Xavier Leroy — the creator of OCaml — reviewed by the core team, and shipped to every user in OCaml 5.5.1.

Why I built this

I was building a trade automation pipeline, and I’d chosen OCaml for the same reason Jane Street swears by it: low latency, high performance, and a type system that catches your mistakes before the market does. Then a malformed input crashed my program in a way that was supposed to be impossible after a recent security fix. I could have worked around it and moved on — instead I pulled the runtime source and started reading. What I found was a small arithmetic mistake with big consequences, sitting inside the security fix itself.

Why it interested me

Honestly, my first plan was to report the crash and get back to my pipeline. But the more I looked, the clearer it became: every OCaml release before 5.5.1 carried this flaw, which meant thousands of developers — and every production system they run — were one malicious input away from leaked memory or a dead process. Just reporting it started to feel like leaving the job half-done. So I wrote up my entire findings, built the proof-of-concepts, proposed a fix and sent it all to OCaml’s team in France. Xavier Leroy, the creator of the language itself, published the fix in OCaml 5.5.1 — with my name on the advisory as the reporter. Not bad for a side quest.

Next project

EY.