Skip to content

Fix OOB reads in sequential mesh decoder and rANS entropy decoder - #1221

Open
smoke-wolf wants to merge 1 commit into
google:mainfrom
smoke-wolf:fix-mesh-decoder-oob
Open

Fix OOB reads in sequential mesh decoder and rANS entropy decoder#1221
smoke-wolf wants to merge 1 commit into
google:mainfrom
smoke-wolf:fix-mesh-decoder-oob

Conversation

@smoke-wolf

Copy link
Copy Markdown

Summary

Two out-of-bounds read bugs in the Draco decoder, both confirmed under AddressSanitizer.

Bug 1: Face index validation missing in sequential decoder

mesh_sequential_decoder.cc — face vertex indices decoded from the bitstream are not validated against num_points. A crafted .drc file with face indices exceeding the vertex count causes heap-buffer-overflow when attributes are accessed via the invalid indices.

Fix: Add if (val >= num_points) return false; to all four face index decode paths (uint8, uint16, varint, uint32).

Bug 2: Missing bounds check in rANS decoder read_init()

ans.hRAnsDecoder::read_init() checks offset < 2 for x==1 and offset < 3 for x==2, but is missing the equivalent offset < 4 check for x==3. A crafted entropy stream reads 4 bytes before the buffer start.

Fix: Add if (offset < 4) return 1; for the x==3 case, matching the existing pattern.

mesh_sequential_decoder.cc: face vertex indices decoded from the
bitstream were not validated against num_points, allowing crafted
meshes to reference nonexistent vertices. Subsequent attribute access
via these indices causes heap-buffer-overflow. Add bounds checking
for all face index decode paths.

ans.h: RAnsDecoder::read_init() was missing a bounds check for the
x==3 case (offset < 4), unlike the x==1 and x==2 cases which had
equivalent guards. A crafted entropy stream with offset=1 and x=3
reads 4 bytes before the buffer start. Add the missing check.

Both bugs confirmed under AddressSanitizer.
@smoke-wolf

smoke-wolf commented Sep 2, 2026

Copy link
Copy Markdown
Author

Discovered by Maliq Barnard. ASAN-confirmed heap-buffer-overflow in sequential mesh decoder (unvalidated face indices) and rANS entropy decoder (missing bounds check for x==3 case) via crafted .drc files.

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