Skip to content

Fix integer overflow in ICC tag offset and parser bounds checks (OSS-Fuzz 501676165)#403

Merged
DichenZhang1 merged 1 commit into
mainfrom
fix-oss-fuzz-501676165
Jul 17, 2026
Merged

Fix integer overflow in ICC tag offset and parser bounds checks (OSS-Fuzz 501676165)#403
DichenZhang1 merged 1 commit into
mainfrom
fix-oss-fuzz-501676165

Conversation

@DichenZhang1

Copy link
Copy Markdown
Collaborator

Problem

On 32-bit platforms (e.g. libfuzzer_asan_i386), size_t is 32-bit (uint32_t). When parsing ICC profiles in IccHelper::readIccColorGamut, tag offsets and sizes read from malformed profiles can cause additive integer wrap-around (e.g., kICCIdentifierSize + cicp_offset + cicp_size <= icc_size wrapping around to 11 <= icc_size). This bypasses bounds checks and causes out-of-bounds heap memory reads (Heap-buffer-overflow READ 1), reported in OSS-Fuzz issue 501676165.

Fix

  • Replaced additive bounds checks with subtraction-based checks across icc.cpp, jpegrutils.cpp, and gainmapmetadata.cpp (offset <= profile_size && size <= profile_size - offset).
  • Added tag count bound checks (tag_count > max_tags) to prevent tag table indexing wrap-around.
  • Added regression test iccIntegerOverflowOffset in tests/icchelper_test.cpp verifying safe handling of wrapping tag offsets.

Fixes OSS-Fuzz 501676165.
Original Piper CL: cl/949044592.

…Fuzz 501676165)

On 32-bit platforms, size_t is 32-bit (uint32_t). When parsing ICC profiles in IccHelper::readIccColorGamut, tag offsets and sizes read from malformed profiles can cause additive integer wrap-around (e.g. kICCIdentifierSize + cicp_offset + cicp_size <= icc_size wrapping around). This bypasses bounds checks and causes out-of-bounds heap memory reads.

This change replaces additive bounds checks with subtraction-based checks across icc.cpp, jpegrutils.cpp, and gainmapmetadata.cpp, adds tag table size validation, and adds a regression test in icchelper_test.cpp.

BUG=501676165
@DichenZhang1
DichenZhang1 merged commit ad4a92e into main Jul 17, 2026
44 checks passed
@DichenZhang1
DichenZhang1 deleted the fix-oss-fuzz-501676165 branch July 17, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant