Repository navigation
Validate fallback Exif offsets before parsing - #22528
Merged
Merged
Conversation
HEIF and JPEG XL files store a big-endian TIFF offset at the start of their Exif payload. Adding four to an attacker-controlled uint32_t before checking the payload size can wrap and pass an out-of-range pointer to the Exif parser. Keep the JPEG XL Exif size separate from subsequent box sizes and check both loaders' offsets by subtraction. Also reject blob lengths that do not fit the Exif parser's int parameter.
Collaborator
|
Thanks @acts-1631 for your contribution! Proper validation to prevent OOB reads and writes is indeed important. I’ll review it soon; one thing I noticed right away: I don’t think it’s worth adding checks to the code for 32-bit platform compatibility. Leaving aside the practical value (which is zero), building darktable on actual 32-bit platforms is virtually impossible. |
victoryforce
reviewed
Oct 7, 2026
victoryforce
reviewed
Oct 7, 2026
victoryforce
reviewed
Oct 7, 2026
victoryforce
reviewed
Oct 7, 2026
victoryforce
reviewed
Oct 7, 2026
victoryforce
reviewed
Oct 7, 2026
Use standard limits and clearer data offset names in both fallback Exif paths. Keep JPEG XL sizes in the decoder API's uint64_t domain and remove unsupported 32-bit compatibility code.
victoryforce
approved these changes
Oct 7, 2026
Contributor
Author
|
Thanks for all your input. |
jenshannoschwalm
approved these changes
Oct 13, 2026
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.
dt_imageio_open_jpegxl()anddt_imageio_open_heif()use the first four bytes of an Exif box or item as an offset to TIFF data when falling back to blob-based metadata parsing. Theirexif_size > 4 + exif_offsetcheck can overflow for a crafted 32-bit offset, allowing a pointer outside the metadata allocation and causing an out-of-bounds read during image import. The JPEG XL path also reused the retained Exif size for later boxes.Use subtraction-based offset validation, reject TIFF blobs too large for
dt_exif_read_from_blob(), and keep JPEG XL's per-box size separate from the retained Exif allocation size. Repeated Exif boxes now replace the previous allocation safely.