fix(tiff): hardening: prevent OOB read, overflow protection - #5336
Open
lgritz wants to merge 1 commit into
Open
Conversation
Collaborator
Author
|
This is the first PR in a new initiative I'm taking to proactively look file format by file format and try to uncover potential bugs before the fuzzers or the bad guys even find them. So expect another series of PRs. I will try to organize them into one per format. |
Collaborator
Author
|
Near as I can tell, the "hobbled" test failures are unrelated to this PR and are happening (nondeterministically) on several branches/PRs. I think it's some kind of GH configuration thing, am looking at it separately. |
In the raw-strip read path of read_native_scanlines(), a failed TIFFReadRawStrip() returns csize < 0. Bail out of the strip loop for this case before running the decompress, matching the existing tiled path (read_native_tiles already breaks on this condition), and guard the leftover-scanline loop with ok so it doesn't run after the bail. Add regression seed to the TIFF corpora -- a valid DEFLATE TIFF with StripOffsets[0] pointing past EOF that the nightly ASan fuzz job exercises via full-image reads. The reader now rejects it with a clean error instead of reading out of bounds. Also size scanline scratch with 64-bit arithmetic, for overflow protection. Assisted-by: Claude Code / Claude Opus 4.8 Signed-off-by: Larry Gritz <lg@larrygritz.com>
lgritz
force-pushed
the
lg-tiff-hardening
branch
from
July 27, 2026 00:45
6f26385 to
ab3793d
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.
In the raw-strip read path of read_native_scanlines(), a failed TIFFReadRawStrip() returns csize < 0. Bail out of the strip loop for this case before running the decompress, matching the existing tiled path (read_native_tiles already breaks on this condition), and guard the leftover-scanline loop with ok so it doesn't run after the bail.
Add regression seed to the TIFF corpora -- a valid DEFLATE TIFF with StripOffsets[0] pointing past EOF that the nightly ASan fuzz job exercises via full-image reads. The reader now rejects it with a clean error instead of reading out of bounds.
Also size scanline scratch with 64-bit arithmetic, for overflow protection.
Assisted-by: Claude Code / Claude Opus 4.8