Prevent panic on invalid palette indices - #180
Draft
jesposito wants to merge 1 commit into
Draft
Conversation
dabao1955
pushed a commit
to NekoSekaiMoe/imaging
that referenced
this pull request
Jul 26, 2026
…ation - fix: prevent panic on invalid paletted image indices (PR disintegration#180) - refactor: replace deprecated io/ioutil with io and os packages (PR disintegration#175) - perf: use unbuffered channel in parallel processing (PR disintegration#162) - fix: update example import path to NekoSekaiMoe Co-authored-by: Claude Opus 4.8 <noreply@anthropic.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.
Summary
image.PalettedWhy
scanner.scancurrently assumes that every byte inimage.Paletted.Pixis a valid index into the image palette. A malformed image can violate that invariant and trigger an index-out-of-range panic. This is the crash reported in #165 and CVE-2023-36308.Newer
golang.org/x/image/tiffversions reject the published malformed TIFF during decoding, butimagingcan still receive an invalid paletted image from callers or older decoders. The defensive check makes the scanner safe independently of the decoder version and keeps compatibility with the existing no-error scanner API.Fixes #165.
Related upstream parser fix: golang/go#67624
Compatibility
This is an internal behavior change with no API changes and remains compatible with the Go versions in the existing Travis matrix.
Validation
masterand passes with this patchgo test -race ./...