Repository navigation
feat!: refuse rare JPEG frame codings and read every picture of an MPF file - #1
Merged
Merged
Conversation
…F file Two checks from a backfill of three years of advisories against the decoders this library stands in front of. A JPEG's start-of-frame marker says how it is coded. The reader now names the coding (baseline, extended, progressive, lossless, hierarchical, arithmetic) and the policy's new jpeg_frames field says which may pass; the default is the three a scanner writes. A lossless frame was the way into a heap overflow in Pillow's JPEG decoder (CVE-2026-112403), and the other rare codings are the decoder's least exercised code. The command takes --jpeg-frames. A JPEG carrying a Multi-Picture Format index (an MPO, which Pillow steps through as frames) now has every picture read with the same bounded walk: each counts as a page, each is checked against max_pixels, and each must match the first in coding and component count, since the decoder sizes its buffers from the first. That closes the second-picture pixel bomb (CVE-2026-96636) and the mode change that overwrote the first picture's buffer (CVE-2026-96639). A malformed index, a picture outside the file or one flagged as not JPEG is a refusal. The entry's size field is ignored, as Pillow's reader ignores it; Pillow 13.0.0's writer gets it wrong from the third picture on. BREAKING CHANGE: a lossless, hierarchical or arithmetic-coded JPEG, and a multi-picture JPEG whose index is malformed or whose pictures differ in coding or components, passed before and are refused now. Co-Authored-By: Claude Fable 5.1 <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.
What
Two header checks for JPEG, from a backfill of three years of advisories against the decoders this library stands in front of.
jpeg_frames, says which may pass. The default is the three a scanner writes. A lossless frame was the way into a heap overflow in Pillow's JPEG decoder (CVE-2026-112403); the other rare codings are the decoder's least exercised code. The command takes--jpeg-frames.max_pixels, and each must match the first in coding and component count, because the decoder sizes its buffers from the first. That closes the second-picture pixel bomb (CVE-2026-96636) and the mode change that overwrote the first picture's buffer (CVE-2026-96639). A malformed index, a picture outside the file, or one flagged as not JPEG is a refusal.Why breaking
A lossless, hierarchical or arithmetic-coded JPEG, and a multi-picture JPEG whose index is malformed or whose pictures differ in coding or components, passed before and are refused now. Under AGENTS.md that is a
!.Notes
Checks
ruff check,ruff format --check,mypy,pytest --cov(151 tests, 97%) anduv lock --checkall pass locally.🤖 Generated with Claude Code