security: add bounds checks to decoder prediction schemes and point count#1197
Open
sharadboni wants to merge 1 commit intogoogle:mainfrom
Open
security: add bounds checks to decoder prediction schemes and point count#1197sharadboni wants to merge 1 commit intogoogle:mainfrom
sharadboni wants to merge 1 commit intogoogle:mainfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
sizeparameter in mesh prediction scheme decodersThe
ComputeOriginalValuesmethod in four mesh prediction scheme decoders(
MeshPredictionSchemeParallelogramDecoder,MeshPredictionSchemeConstrainedMultiParallelogramDecoder,MeshPredictionSchemeMultiParallelogramDecoder,MeshPredictionSchemeGeometricNormalDecoder) had thesizeparametercommented out (
int /* size */) and usedcorner_map_sizefrom mesh dataas the loop bound instead.
When
corner_map_size > size / num_components, the loop writes past the endof
out_data, causing a heap buffer overflow. The corner map and attributearrays are both populated from compressed data, so an attacker can craft a
DRC file where they diverge.
Fix: Restore the
sizeparameter and add a guard:Vulnerability 5: Negative point count in PointCloudSequentialDecoder
DecodeGeometryDatareadsnum_pointsasint32_tfrom the bitstreamwithout checking for negative values. A negative value implicitly converts
to a very large
uint32_twhen passed toset_num_points, causingdownstream heap overflow.
Fix: Reject negative point counts:
Testing
All 25 existing
.drctest files intestdata/decode correctly with thefixed decoder under AddressSanitizer.