Skip to content

security: add bounds checks to decoder prediction schemes and point count#1197

Open
sharadboni wants to merge 1 commit intogoogle:mainfrom
sharadboni:fix/security-decoder-bounds-checks
Open

security: add bounds checks to decoder prediction schemes and point count#1197
sharadboni wants to merge 1 commit intogoogle:mainfrom
sharadboni:fix/security-decoder-bounds-checks

Conversation

@sharadboni
Copy link
Copy Markdown

Summary

This PR fixes five heap-buffer-overflow and negative-integer vulnerabilities
in the Draco 3D decoder discovered through security analysis.

Vulnerabilities 1–4: Ignored size parameter in mesh prediction scheme decoders

The ComputeOriginalValues method in four mesh prediction scheme decoders
(MeshPredictionSchemeParallelogramDecoder,
MeshPredictionSchemeConstrainedMultiParallelogramDecoder,
MeshPredictionSchemeMultiParallelogramDecoder,
MeshPredictionSchemeGeometricNormalDecoder) had the size parameter
commented out (int /* size */) and used corner_map_size from mesh data
as the loop bound instead.

When corner_map_size > size / num_components, the loop writes past the end
of out_data, causing a heap buffer overflow. The corner map and attribute
arrays are both populated from compressed data, so an attacker can craft a
DRC file where they diverge.

Fix: Restore the size parameter and add a guard:

if (corner_map_size * num_components > size) {
  return false;
}

Vulnerability 5: Negative point count in PointCloudSequentialDecoder

DecodeGeometryData reads num_points as int32_t from the bitstream
without checking for negative values. A negative value implicitly converts
to a very large uint32_t when passed to set_num_points, causing
downstream heap overflow.

Fix: Reject negative point counts:

if (num_points < 0) {
  return false;
}

Testing

All 25 existing .drc test files in testdata/ decode correctly with the
fixed decoder under AddressSanitizer.

…ount

Fix four heap-buffer-overflow vulnerabilities in mesh prediction scheme
decoders and a negative-point-count bug in the sequential decoder:

1. mesh_prediction_scheme_parallelogram_decoder.h:
   ComputeOriginalValues silently discarded the `size` parameter and
   iterated up to corner_map_size, which may exceed the actual output
   buffer allocation. Add a guard: corner_map_size * num_components > size.

2. mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h:
   Same pattern — size was ignored. Add identical guard.

3. mesh_prediction_scheme_multi_parallelogram_decoder.h:
   Same pattern. Add identical guard.

4. mesh_prediction_scheme_geometric_normal_decoder.h:
   Same pattern. Add identical guard.

5. point_cloud_sequential_decoder.cc:
   num_points is decoded from the bitstream as int32_t with no validation.
   A negative value implicitly converts to a huge uint32_t and causes
   downstream heap overflow. Reject negative point counts.
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