fix: Harden against integer underflow in JUMBF box parsers#2200
Merged
Conversation
1b6c03c to
9ebd5e9
Compare
3 tasks
tmathern
approved these changes
Jun 3, 2026
9ebd5e9 to
04fe558
Compare
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.
Vulnerability
7 functions in
sdk/src/jumbf/boxes.rscomputesize - HEADER_SIZEon attacker-controlledsizevalues without first validatingsize >= HEADER_SIZE. A 207-byte malformed JPEG with a JUMBF box declaringsize = 4triggersattempt to subtract with overflowduring JUMBF structural parsing.Fix
Replace
size - HEADER_SIZEwithsize.checked_sub(HEADER_SIZE).ok_or(InvalidBoxHeader)?at each of the 7 reported sites:read_json_boxread_cbor_boxread_padding_boxread_jp2c_boxread_brotli_boxread_embedded_content_boxread_super_box_implunknown box handlerTests
Added 7 regression tests covering all 7 fix paths.
Checklist
TO DOitems have been entered as GitHub issues and the link has been included in a comment.