Skip to content

io: validate vertex, texture, and normal index bounds in obj decoder (fixes #1194) - #1243

Open
jdymitarai wants to merge 1 commit into
google:mainfrom
jdymitarai:fix-obj-decoder-face-index-bounds-1194
Open

jdymitarai wants to merge 1 commit into
google:mainfrom
jdymitarai:fix-obj-decoder-face-index-bounds-1194

Conversation

@jdymitarai

@jdymitarai jdymitarai commented Oct 4, 2026 •

Copy link
Copy Markdown

Root Cause

In ObjDecoder, face corner indices were parsed without checking whether referenced vertex, texture, or normal indices exceeded the counts of defined attributes or were negative beyond the start offset. Out-of-bounds indices were stored directly into attribute point mappings, causing heap buffer overflows during attribute deduplication (PointAttribute::DeduplicateFormattedValues). Furthermore, malformed trailing corner indices on quads/polygons (such as index 0 or invalid attribute declarations) prematurely broke parsing without verifying genuine end-of-line, leaving uninitialized faces and points.

Fix

  • In ObjDecoder::ParseFace, check genuine line termination (\n, \r, #, or EOF) before breaking on trailing corners so malformed polygon indices cannot bypass parsing, and validate all corner indices fall within valid bounds for defined attributes before triangulation and mapping, returning Status::DRACO_ERROR ("Face index out of range") if any index is out of bounds.
  • In ObjDecoder::MapPointToVertexIndices, add defensive bounds validation rejecting invalid attribute indices (including 0 position indices).

Verification

  • Added ObjDecoderTest.RejectOutOfRangeIndices covering positive and negative out-of-range position, texture, and normal indices for mesh and point cloud decoding, quads/n-gons with invalid 4th corner indices, and malformed corner 0 declarations.
  • Ran all existing Draco unit tests (draco_tests), passing 189/189 tests cleanly without regressions.

@jdymitarai
jdymitarai force-pushed the fix-obj-decoder-face-index-bounds-1194 branch from 37d2ee6 to c32790b Compare October 4, 2026 20:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant