fix: integer overflow in face/point count multiplications → heap overflow#1166
fix: integer overflow in face/point count multiplications → heap overflow#1166mohammadmseet-hue wants to merge 1 commit intogoogle:mainfrom
Conversation
Multiple locations in the Unity plugin, JavaScript/WASM wrapper, and Maya plugin compute buffer sizes as num_faces * 3 or num_points * N without checking for integer overflow. When the product overflows (wraps to a small value), a tiny buffer is allocated and subsequent loops write the full count of entries, causing a heap buffer overflow. This is exploitable on 32-bit platforms (WASM32, 32-bit Unity builds) where the overflow threshold is practical (e.g., num_faces > ~1.4 billion causes num_faces * 3 to wrap). Affected locations: - unity/draco_unity_plugin.cc: GetMeshIndices, DecodeDracoMeshStep2 (indices, positions, normals, colors, texcoords) - javascript/emscripten/decoder_webidl_wrapper.cc: GetTrianglesArray - maya/draco_maya_plugin.cc: decode_faces Fix: add overflow checks before each unchecked multiplication.
ASan ConfirmationBuilt with PoC 1: Simple overflow patternPoC 2: Realistic pattern using draco::Mesh + memcpy (exact code from draco_unity_plugin.cc:242)Both PoCs use the exact |
ASan proof for the
|
Summary
Multiple locations in the Unity plugin, JavaScript/WASM decoder wrapper, and Maya plugin compute buffer sizes using
num_faces * 3ornum_points * Nwith attacker-controlled values from the Draco bitstream, without checking for integer overflow. When the product wraps to a small value, a tiny buffer is allocated and subsequent loops write the full (unwrapped) count of entries, causing a heap buffer overflow.Severity
Critical — Heap buffer overflow from crafted Draco files. Affects:
Vulnerable Code
1. JavaScript/WASM Decoder (decoder_webidl_wrapper.cc:178)
On WASM32,
sizeof(T)=4, so357913942 * 3 * 4 = 4294967304wraps to8. Ifout_size=8, the check passes and the loop writes ~1.4B entries into an 8-byte buffer.2. Unity Plugin (draco_unity_plugin.cc:239, 335, 343, 358, 373, 393)
3. Maya Plugin (draco_maya_plugin.cc:23)
Trigger
num_faces = 1431655766(just over UINT32_MAX / 3):1431655766 * 3 = 4294967298→ overflows 32-bit to2new int[2]allocates 8 bytes1431655766 * 3 = ~4.3 billionentries → heap overflowNote
The core decoder (
mesh/corner_table.cc:63) does have an overflow check fornum_faces * 3. But the binding/extraction layer (Unity, WASM, Maya) where decoded data is copied to caller buffers has no overflow protection. Existing fuzz targets do not cover these code paths.Fix
Added overflow checks before each unchecked multiplication in the Unity, WASM, and Maya plugins.