Fix heap OOB read in PLY reader from unchecked list entry count#1205
Open
gn00295120 wants to merge 1 commit into
Open
Fix heap OOB read in PLY reader from unchecked list entry count#1205gn00295120 wants to merge 1 commit into
gn00295120 wants to merge 1 commit into
Conversation
PlyReader::ParseElementData uses a file-supplied list entry count to compute a copy size without checking the buffer has that many bytes. A truncated binary PLY with a large list count causes a heap OOB read. - Check Decode() return value for the list count - Reject negative entry counts - Validate num_bytes_to_read against remaining_size() - Add remaining_size() check for non-list property reads
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
PlyReader::ParseElementDatareads a list entry count from the PLY file and uses it to compute how many bytes to copy from the buffer, without checking that the buffer actually contains that much data. A PLY file with a large list count and truncated data triggers a heap-buffer-overflow read. TheDecode()return value for the count itself was also silently ignored.The same issue exists for non-list properties:
data_type_num_bytes()bytes are copied from the buffer without checkingremaining_size().Changes
Decode()return value when reading the list entry countnum_bytes_to_read <= remaining_size()before the copy (also prevents integer overflow in the multiplication)remaining_size()check for non-list property readsReproduction
ASAN trace (before fix):