zero-fill deep sample-count table for zero-length compressed input#2550
Open
cary-ilm wants to merge 1 commit into
Open
zero-fill deep sample-count table for zero-length compressed input#2550cary-ilm wants to merge 1 commit into
cary-ilm wants to merge 1 commit into
Conversation
A crafted compressed deep-scanline (or deep-tiled) EXR chunk that declares a zero-length sample-count table causes exr_decoding_run() to read uninitialized heap memory in unpack_sample_table(). exr_read_scanline_chunk_info() rejects a negative sample-table size but accepts zero for compressed deep chunks. default_read_chunk() only allocates and reads packed_sample_count_table when the declared size is greater than zero, so it stays NULL. update_pack_unpack_ptrs() still allocates the full decompressed sample_count_table (width * height * sizeof(int32_t)) without initializing it, and exr_uncompress_chunk() skips decompress_data() entirely when packed_sample_count_table is NULL. The existing zero-fill safeguard in exr_decoding_run() only covered EXR_COMPRESSION_NONE, so for any other compression type the uninitialized buffer was passed straight into unpack_sample_table(), which reads it to check sample-count monotonicity and compute the total sample count. Fix: when a compressed deep chunk has no packed sample-count table (packed_sample_count_table == NULL, i.e. the declared table size is zero), zero-fill the allocated sample_count_table before unpack_sample_table() runs, treating the absent table as all-zero sample counts instead of leaving it uninitialized. This matches the remediation suggested in the advisory report. Addresses https://github.com/AcademySoftwareFoundation/openexr/security/advisories/GHSA-prr3-4q3r-hmf3 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Cary Phillips <seabeepea@gmail.com>
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.
A crafted compressed deep-scanline (or deep-tiled) EXR chunk that declares a zero-length sample-count table causes exr_decoding_run() to read uninitialized heap memory in unpack_sample_table().
exr_read_scanline_chunk_info() rejects a negative sample-table size but accepts zero for compressed deep chunks. default_read_chunk() only allocates and reads packed_sample_count_table when the declared size is greater than zero, so it stays NULL. update_pack_unpack_ptrs() still allocates the full decompressed sample_count_table (width * height * sizeof(int32_t)) without initializing it, and exr_uncompress_chunk() skips decompress_data() entirely when packed_sample_count_table is NULL. The existing zero-fill safeguard in exr_decoding_run() only covered EXR_COMPRESSION_NONE, so for any other compression type the uninitialized buffer was passed straight into unpack_sample_table(), which reads it to check sample-count monotonicity and compute the total sample count.
Fix: when a compressed deep chunk has no packed sample-count table (packed_sample_count_table == NULL, i.e. the declared table size is zero), zero-fill the allocated sample_count_table before unpack_sample_table() runs, treating the absent table as all-zero sample counts instead of leaving it uninitialized. This matches the remediation suggested in the advisory report.
Addresses https://github.com/AcademySoftwareFoundation/openexr/security/advisories/GHSA-prr3-4q3r-hmf3