Skip to content

fix: validate face vertex indices in sequential decoder to prevent OOB access#1167

Open
mohammadmseet-hue wants to merge 1 commit intogoogle:mainfrom
mohammadmseet-hue:fix/validate-face-vertex-indices
Open

fix: validate face vertex indices in sequential decoder to prevent OOB access#1167
mohammadmseet-hue wants to merge 1 commit intogoogle:mainfrom
mohammadmseet-hue:fix/validate-face-vertex-indices

Conversation

@mohammadmseet-hue
Copy link
Copy Markdown

Summary

The sequential mesh decoder reads face vertex indices from the Draco bitstream without validating that they fall within [0, num_points). When a crafted Draco file contains out-of-range indices, attribute access via GeometryAttribute::GetValue() causes an out-of-bounds heap read.

ASan Proof

==ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 12 at 0x507000000540 thread T0
    #0 in memcpy
    #1 in draco::DataBuffer::Read (data_buffer.h:48)
    #2 in draco::GeometryAttribute::GetValue (geometry_attribute.h:138)

0x507000000540 is located 1128 bytes after 72-byte region [0x507000000090,0x5070000000d8)

A 72-byte attribute buffer (6 points × 12 bytes) was accessed at index 100 (offset 1200) — 1128 bytes past the end.

Root Cause

mesh_sequential_decoder.cc lines 74-125: all four index decoding paths (uint8, uint16, uint32 varint, uint32 direct) store indices from the stream into face[j] without checking val < num_points. The compressed index path (DecodeAndDecompressIndices) has the same issue.

Impact

Any application that decodes attacker-provided .drc files is affected. The OOB read can leak heap data. Combined with attribute write operations (deduplication, transforms), this could potentially become an OOB write.

Fix

Added a validation pass after decoding connectivity that checks all face vertex indices are within [0, num_points).

Separate from PR #1166

This is a different root cause from the integer overflow in PR #1166:

…coder

The sequential mesh decoder reads face vertex indices from the bitstream
without validating that they fall within [0, num_points). When a crafted
Draco file contains face indices exceeding num_points, subsequent attribute
access via these indices causes out-of-bounds heap reads (and potentially
writes during attribute deduplication or other operations).

ASan confirms the OOB:
  ERROR: AddressSanitizer: heap-buffer-overflow
  READ of size 12 at <addr>
  <addr> is located 1128 bytes after 72-byte region

This affects all four index decoding paths (uint8, uint16, uint32 varint,
uint32 direct) and the compressed index path (DecodeAndDecompressIndices).

Fix: add a validation pass after decoding connectivity that checks all
face vertex indices are within the valid range [0, num_points).
@mohammadmseet-hue
Copy link
Copy Markdown
Author

ASan Confirmation

Built with -fsanitize=address and confirmed the out-of-bounds heap read:

==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x507000000540
READ of size 12 at 0x507000000540 thread T0
    #0 in memcpy
    #1 in draco::DataBuffer::Read (data_buffer.h:48)
    #2 in draco::GeometryAttribute::GetValue (geometry_attribute.h:138)
    #3 in main poc_index_oob.cc:70

0x507000000540 is located 1128 bytes after 72-byte region [0x507000000090,0x5070000000d8)
allocated by thread T0 here:
    #0 in operator new(unsigned long)
    #1 in std::__new_allocator<unsigned char>::allocate
    ...
    #8 in draco::PointAttribute::Reset (point_attribute.cc:71)
    #9 in draco::PointCloud::CreateAttribute (point_cloud.cc:167)
    #10 in draco::PointCloud::AddAttribute (point_cloud.cc:142)

SUMMARY: AddressSanitizer: heap-buffer-overflow in memcpy

The 72-byte attribute buffer (6 points × 12 bytes/entry) was accessed at index 100 (offset 1200) — 1128 bytes past the buffer end. The face vertex index 100 was stored without validation against num_points=6.

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