Skip to content

Validate ICC configured size does not surpass bmp file size - #3095

Merged
197g merged 1 commit into
image-rs:mainfrom
telecos:fix/bmp-icc-profile-bounds-crbug-537617325
Aug 3, 2026
Merged

Validate ICC configured size does not surpass bmp file size#3095
197g merged 1 commit into
image-rs:mainfrom
telecos:fix/bmp-icc-profile-bounds-crbug-537617325

Conversation

@telecos

@telecos telecos commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This PR hardens BMP V5 embedded ICC profile handling.

The decoder now validates the declared ICC profile byte range before allocating the profile buffer. It computes profile_offset + profile_size with overflow checking, compares the result against the seekable input length, and returns an UnexpectedEof`` error if the profile extends beyond the file. The profile buffer allocation now also uses the crate’s fallible allocation helper instead of direct vec![...]` allocation.

A regression test was added for the Chromium issue 537617325 crash class. The test builds an in-memory 138-byte BMP V5 file with bV5CSType == "MBED", bV5ProfileData == 0x90, and bV5ProfileSize == u32::MAX, then verifies that decoder construction fails with UnexpectedEof instead of attempting to allocate the declared profile size.

This fixes #3094

@197g
197g merged commit 2c37455 into image-rs:main Aug 3, 2026
31 checks passed
scadastrangelove added a commit to scadastrangelove/rust-in-peace that referenced this pull request Aug 4, 2026
… number

Chromium issue was mis-recorded as 537617321 since filing (2026-07-22); the
real number is 537617325, confirmed via the Buganizer notification and
image-rs/image#3094 independently citing it. telecos (Microsoft/Edge)
root-caused our report into image-rs/image and merged a fix same day
(2026-08-03); Chromium's own vendored copy isn't confirmed updated yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
brave-builds pushed a commit to brave/chromium that referenced this pull request Aug 5, 2026
Incorporate patch from image crate PR:

image-rs/image#3095

To validate that icc profile size is not surpassing remaining stream
size. Add regression test for the case.

Bug: 537617325
Change-Id: Id1459a21f9fbb9a58ff05e4e8346eab508e81943
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8183991
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Sergio Gonzalez Martin <sergiog@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1674242}
mohd-akram pushed a commit to gsource-mirror/chromium-src-third_party-rust that referenced this pull request Aug 5, 2026
Incorporate patch from image crate PR:

image-rs/image#3095

To validate that icc profile size is not surpassing remaining stream
size. Add regression test for the case.

Bug: 537617325
Change-Id: Id1459a21f9fbb9a58ff05e4e8346eab508e81943
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8183991
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Sergio Gonzalez Martin <sergiog@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1674242}
NOKEYCHECK=True
GitOrigin-RevId: 685d6eac6a9cd2eea74ea50589447ad809093634
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.

Missing validation on ICC profile size embedded in BMP file

2 participants