Fix heap OOB read in STL decoder from missing buffer bounds checks#1203
Open
gn00295120 wants to merge 1 commit into
Open
Fix heap OOB read in STL decoder from missing buffer bounds checks#1203gn00295120 wants to merge 1 commit into
gn00295120 wants to merge 1 commit into
Conversation
StlDecoder::DecodeFromBuffer reads header bytes, face count, and per-face data without verifying the buffer is large enough. A truncated STL file causes a heap-buffer-overflow read. - Require at least 84 bytes before reading header + face count - Check Decode() return values instead of ignoring them - Validate face_count against remaining buffer before the parse loop
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
StlDecoder::DecodeFromBufferreads an 80-byte header, a 4-byte face count, and 50 bytes per face from the input buffer without checking that the buffer is large enough. A truncated or malicious STL file triggers a heap-buffer-overflow read.Changes
Decode()return value for the face count (was silently ignored)face_countagainstremaining_size() / 50before entering the parse loopDecode()return values inside the loopReproduction
ASAN trace (before fix):