Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ check(path, Policy(formats={"tiff", "pdf"}, max_pages=50))
| `jpeg_frames` | baseline, extended, progressive | the same | How a JPEG's frame may be coded. Lossless, hierarchical and arithmetic frames are legal JPEG that no scanner writes and the decoder's least-exercised code; a lossless frame was the way into a heap overflow in Pillow's JPEG decoder (CVE-2026-112403) |
| `tiff_tags` | standard, metadata, private | the same | Which kinds of tag a TIFF's directories may hold. Standard is the TIFF 6.0 set; metadata the registered blocks (XMP, IPTC, Photoshop, Exif, ICC, GPS, GeoTIFF); private everything else, the vendor and DNG tags a scan never carries. A read is not harmed by a private tag, so the default allows all three; a program that saves a file back as TIFF with its tag table carries every tag into libtiff's encoder, where a crafted one copied process memory into the output (CVE-2026-112902), and should allow standard and metadata only |
| `allow_inconsistent_tiff_tags` | no | no | Pass a TIFF whose tags contradict each other: a ColorMap of the wrong size for the bit depth (CVE-2026-112896), a floating-point Predictor on integer samples (CVE-2026-112396). No scanner writes either; both reach an encoder that trusts the tag, so the default refuses them, malformed by design or by accident. Allow only for a source known to write such files |
| `allow_overlapping_tag_data` | no | no | Pass a file with a tag directory whose tags claim more data between them than the file holds: a TIFF's frame or one of the Exif, GPS and interoperability directories it points to, or, measured against the block itself, the EXIF block of a JPEG or a PNG and a JPEG's multi-picture index. A decoder reads every tag's value into memory as it loads a directory, and nothing in the format stops each of thousands of tags from pointing at the same bytes: a 144 KB TIFF cost Pillow 1.6 GB to open, and a 66 KB JPEG 340 MB (CVE-2026-128066). The values of an honest directory do not overlap, so they cannot add up to more than the bytes they are read from, and no writer produces a file that fails this. Not seen: EXIF that a PNG carries in a text chunk, which may be compressed, and a camera maker's own directory inside a maker note |
| `allow_spare_tiff_samples` | yes | yes | Pass a greyscale or palette TIFF whose pixels carry more samples than the one the image uses, where the rest are not a single alpha sample (two samples per pixel with ExtraSamples 0, "unspecified data"). A valid TIFF that no scanner writes; a decoder drops the spare sample, so a read is not harmed and the default allows it. A program that saves such a file back as a compressed TIFF carries its SamplesPerPixel tag into libtiff's encoder, which read two samples for every one in the row it was given and copied process memory into the output (CVE-2026-128067), and should refuse them. An alpha channel, and a spare sample on an RGB or CMYK TIFF, are not refused: there the decoder's own count is what the encoder is given |
| `allow_encrypted_pdf` | no | no | A scanned book is never encrypted |
| `pdf_features` | none | none | Which of JavaScript, forms, attached files and launch actions a PDF may carry. Each makes a viewer do something other than draw the page, and a scanned book has none. Forms are read from `pdfinfo`'s report and attached files from `pdfdetach`'s; a launch action is found by its name in the file, since no poppler tool reports one; JavaScript is looked for both ways |
Expand Down Expand Up @@ -173,18 +174,22 @@ prints one object per line for a pipeline; `-q` prints only refusals.
3. **Name against contents.** `says PNG, is JPEG`.
4. **The header**, with a reader of its own for each raster format: the
dimensions, coding and component count from a JPEG's frame header, the
size of its colour profile, and every picture of a multi-picture (MPF)
size of its colour profile and the tag directories of its EXIF block,
from every segment up to the start of the image data, as a decoder
reads them, and every picture of a multi-picture (MPF)
JPEG, each read the same way and required to match the first; a PNG's
whole `IHDR` (bit depth, colour type, interlacing, and the methods the
specification fixes), its `acTL` frame count, and the size of every
other chunk, before and after the image data; and every directory in a TIFF's
specification fixes), its `acTL` frame count, the size of every
other chunk, before and after the image data, and the tag directories
of an `eXIf` chunk; and every directory in a TIFF's
chain, each with its dimensions, its
compression scheme, which must be one the policy names, and its pixel
layout (photometric interpretation and, for YCbCr, chroma subsampling,
both of which the policy names; samples per pixel; bits per sample),
all of which must be the same in every frame, since the decoder sizes
its buffers from the first, its tile size if it is tiled, every
tag's data checked to lie inside the file, every tag sorted into
tag's data checked to lie inside the file and, added together, to be
no more than the file holds, every tag sorted into
standard, metadata or private, and its ColorMap and Predictor checked
against its samples; the chain is walked with a limit and a memory of where it has
been, so that one that loops or points off the end of the file is a
Expand Down Expand Up @@ -250,7 +255,7 @@ a PNG whose header pairs a colour type with a bit depth it cannot have, a
TIFF whose tag points past the end of the file, a lossless JPEG, a multi-picture JPEG whose second picture is four billion
pixels or changes colour mode, a PixarLog-compressed TIFF, a CIELab TIFF, a YCbCr TIFF subsampled four to one, a TIFF that
changes compression or colour mode between frames, a TIFF whose tiles are four billion pixels each, a TIFF with ten thousand frames, a
TIFF whose frame chain loops, a PDF of a thousand pages, a PDF with a page 200
TIFF whose frame chain loops, a TIFF, a JPEG and a PNG whose tags all claim the same bytes, a PDF of a thousand pages, a PDF with a page 200
inches wide. Nothing hostile is
checked in. The readers are also checked against Pillow's reading of real
files, so that they agree with the decoder they stand in front of.
Expand Down
45 changes: 41 additions & 4 deletions docs/advisories/record.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"other": "some other way; the finding says"
},
"counts": {
"records": 125,
"refused_by_default": 46,
"records": 126,
"refused_by_default": 47,
"by_bucket": {
"A": 39,
"B": 20,
"B": 21,
"B2": 3,
"C": 19,
"D": 3,
Expand All @@ -31,7 +31,7 @@
"by_library": {
"FreeType": 4,
"OpenJPEG": 6,
"Pillow": 62,
"Pillow": 63,
"libpng": 15,
"libtiff": 18,
"poppler": 16,
Expand Down Expand Up @@ -74,6 +74,43 @@
"checked": "2026-11-16",
"notes": "Triaged from the advisory's text on 2026-11-16, and the bucket confirmed by a person the same day. The words filter labelled the issue likely-not-reached on \"saving\"; read against the question of what rides from an opened file into a save, the file is the input. The advisory names the palette layout for the bare save; the greyscale one was found by trying a bare save of each layout on Pillow 13.0.0, where the encoder's new guard refuses (encoder error -8) the greyscale and the palette image with an unspecified sample, and no image with an alpha channel, nor RGB or CMYK with a spare sample. The overflow itself was not reproduced on an earlier Pillow. The policy was built on 2026-11-16."
},
{
"key": "CVE-2026-128066",
"aliases": [],
"library": "Pillow",
"package": "pillow",
"ecosystem": "PyPI",
"title": "Tags that all claim the same bytes make Pillow hold thousands of times a file's size in memory",
"summary": "Pillow: Memory DoS in TIFF and EXIF IFD parsing via overlapping tag data",
"published": "2026-11-12",
"severity": null,
"affected": "< 13.0.0",
"fixed": "13.0.0",
"reached_by": "open",
"trigger": "Opening a TIFF or a JPEG whose tag directory holds thousands of tags that each claim the same bytes as their value; for a PNG, asking for the EXIF of one.",
"bucket": "B",
"finding": "The trigger is a tag directory, which is a header: each entry gives the size of its value and where it lies, and the loader reads every value into memory with nothing to stop them all being the same bytes. The values of an honest directory do not overlap, so they cannot add up to more than the bytes they are read from, and the reader now adds them up: for each frame of a TIFF and the Exif, GPS and interoperability directories it points to, against the file; for the EXIF block of a JPEG or a PNG (its main, thumbnail, Exif, GPS and interoperability directories) and a JPEG's multi-picture index, against the block. A directory that claims more is refused by default, as is a block whose directories hold more entries between them than it has bytes for. The JPEG walk now goes on past the frame header to the image data, since Pillow reads an EXIF block from anywhere before the scan. The advisory's own TIFF was already refused, by accident: its tags point at the second byte of the file, inside the header, which the reader does not allow; moved eight bytes on, it passed every policy. Refusing private tags did not help, since the standard numbers serve as well. Two carriers are not seen: EXIF that a PNG holds in a text chunk (\"Raw profile type exif\"), which may be compressed and so cannot be read without inflating it, and a camera maker's own directory inside a maker note. Both are reached only when a program asks for the EXIF, not on opening.",
"refusal": {
"check": "allow_overlapping_tag_data",
"default": true,
"setting": "allow_overlapping_tag_data"
},
"verified_by": [
"tests/test_check.py::TestHostileFiles::test_a_tiff_whose_tags_all_claim_the_same_bytes",
"tests/test_check.py::TestHostileFiles::test_a_jpeg_whose_exif_tags_all_claim_the_same_bytes",
"tests/test_check.py::TestHostileFiles::test_a_png_whose_exif_tags_all_claim_the_same_bytes"
],
"protect": {
"general": "Upgrade to Pillow 13.0.0, whose loader skips a tag once the directory's values add up to more than the stream.",
"specific": "Keep allow_overlapping_tag_data off, as it is by default; on a Pillow before 13.0.0, do not ask for the EXIF of a PNG from outside (getexif, ImageOps.exif_transpose) unless its text chunks are known to hold none; upgrade to Pillow 13.0.0."
},
"sources": [
"https://osv.dev/vulnerability/GHSA-wqgw-9xfh-qf2g"
],
"triaged": "2026-11-16",
"checked": "2026-11-16",
"notes": "Triaged from the advisory's text on 2026-11-16, and the bucket and the default confirmed by a person the same day. Upstream gives the severity as moderate, with no score. Each route was tried on Pillow 13.0.0, whose bounded loader warns where it used to read: a TIFF, a JPEG's EXIF block before or after the frame header and across several segments, and a JPEG's multi-picture index all reach the loader inside Image.open; a PNG's eXIf chunk and its raw-profile text chunk, compressed or not, on getexif; the Exif and GPS directories on get_ifd. An EXIF block with a BigTIFF header does not reach it. The reader was run over 3.2 million real images (7,501 JPEG, 126,337 TIFF, 3,064,088 PNG) and reported an overlap in none. The memory cost itself was not reproduced on an earlier Pillow. The check was built on 2026-11-16."
},
{
"key": "CVE-2026-107080",
"aliases": [],
Expand Down
37 changes: 37 additions & 0 deletions docs/advisories/record/CVE-2026-128066.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"key": "CVE-2026-128066",
"aliases": [],
"library": "Pillow",
"package": "pillow",
"ecosystem": "PyPI",
"title": "Tags that all claim the same bytes make Pillow hold thousands of times a file's size in memory",
"summary": "Pillow: Memory DoS in TIFF and EXIF IFD parsing via overlapping tag data",
"published": "2026-11-12",
"severity": null,
"affected": "< 13.0.0",
"fixed": "13.0.0",
"reached_by": "open",
"trigger": "Opening a TIFF or a JPEG whose tag directory holds thousands of tags that each claim the same bytes as their value; for a PNG, asking for the EXIF of one.",
"bucket": "B",
"finding": "The trigger is a tag directory, which is a header: each entry gives the size of its value and where it lies, and the loader reads every value into memory with nothing to stop them all being the same bytes. The values of an honest directory do not overlap, so they cannot add up to more than the bytes they are read from, and the reader now adds them up: for each frame of a TIFF and the Exif, GPS and interoperability directories it points to, against the file; for the EXIF block of a JPEG or a PNG (its main, thumbnail, Exif, GPS and interoperability directories) and a JPEG's multi-picture index, against the block. A directory that claims more is refused by default, as is a block whose directories hold more entries between them than it has bytes for. The JPEG walk now goes on past the frame header to the image data, since Pillow reads an EXIF block from anywhere before the scan. The advisory's own TIFF was already refused, by accident: its tags point at the second byte of the file, inside the header, which the reader does not allow; moved eight bytes on, it passed every policy. Refusing private tags did not help, since the standard numbers serve as well. Two carriers are not seen: EXIF that a PNG holds in a text chunk (\"Raw profile type exif\"), which may be compressed and so cannot be read without inflating it, and a camera maker's own directory inside a maker note. Both are reached only when a program asks for the EXIF, not on opening.",
"refusal": {
"check": "allow_overlapping_tag_data",
"default": true,
"setting": "allow_overlapping_tag_data"
},
"verified_by": [
"tests/test_check.py::TestHostileFiles::test_a_tiff_whose_tags_all_claim_the_same_bytes",
"tests/test_check.py::TestHostileFiles::test_a_jpeg_whose_exif_tags_all_claim_the_same_bytes",
"tests/test_check.py::TestHostileFiles::test_a_png_whose_exif_tags_all_claim_the_same_bytes"
],
"protect": {
"general": "Upgrade to Pillow 13.0.0, whose loader skips a tag once the directory's values add up to more than the stream.",
"specific": "Keep allow_overlapping_tag_data off, as it is by default; on a Pillow before 13.0.0, do not ask for the EXIF of a PNG from outside (getexif, ImageOps.exif_transpose) unless its text chunks are known to hold none; upgrade to Pillow 13.0.0."
},
"sources": [
"https://osv.dev/vulnerability/GHSA-wqgw-9xfh-qf2g"
],
"triaged": "2026-11-16",
"checked": "2026-11-16",
"notes": "Triaged from the advisory's text on 2026-11-16, and the bucket and the default confirmed by a person the same day. Upstream gives the severity as moderate, with no score. Each route was tried on Pillow 13.0.0, whose bounded loader warns where it used to read: a TIFF, a JPEG's EXIF block before or after the frame header and across several segments, and a JPEG's multi-picture index all reach the loader inside Image.open; a PNG's eXIf chunk and its raw-profile text chunk, compressed or not, on getexif; the Exif and GPS directories on get_ifd. An EXIF block with a BigTIFF header does not reach it. The reader was run over 3.2 million real images (7,501 JPEG, 126,337 TIFF, 3,064,088 PNG) and reported an overlap in none. The memory cost itself was not reproduced on an earlier Pillow. The check was built on 2026-11-16."
}
1 change: 1 addition & 0 deletions docs/advisories/seen.json
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@
"CVE-2026-112901",
"CVE-2026-112902",
"CVE-2026-114501",
"CVE-2026-128066",
"CVE-2026-128067",
"CVE-2026-12912",
"CVE-2026-18495",
Expand Down
8 changes: 8 additions & 0 deletions scripts/fuzz_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def seeds() -> list[bytes]:
corpus.tiff([(64, 64)], endian=">"),
corpus.tiled_tiff(256, 256, 64),
corpus.spare_sample_tiff(64, 8),
corpus.overlapping_tiff(40),
corpus.overlapping_tiff(40, pointer=34665),
corpus.jpeg(64, 64, before_sof=corpus.jpeg_exif(corpus.overlapping_block(40))),
corpus.jpeg(
64, 64, after_sof=corpus.jpeg_exif(corpus.overlapping_block(40, pointer=34853))
),
corpus.jpeg(64, 64, before_sof=corpus.jpeg_mp_index(corpus.overlapping_block(40))),
corpus.png(64, 64, extra=corpus.png_exif(corpus.overlapping_block(40))),
]
try:
from PIL import Image
Expand Down
12 changes: 12 additions & 0 deletions src/sillybos/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class Facts:
palette TIFF carries beyond the one the image uses, unless
that is a single alpha sample. 0 for every other TIFF and
for the other formats.
overlaps: Each tag directory whose tags claim more data between
them than the file holds, in a sentence: a TIFF's frame or
one of the directories it points to, the EXIF block of a
JPEG or a PNG, a JPEG's multi-picture index. Empty when none
does, and for a PDF.
"""

bytes: int
Expand All @@ -118,6 +123,7 @@ class Facts:
tags: tuple[tuple[str, int], ...] = ()
inconsistencies: tuple[str, ...] = ()
spare_samples: int = 0
overlaps: tuple[str, ...] = ()


@dataclass(frozen=True)
Expand Down Expand Up @@ -274,6 +280,7 @@ def _facts(path: Path, fmt: str, f: headers.Reader, size: int, policy: Policy) -
tags=header.tags,
inconsistencies=header.inconsistencies,
spare_samples=header.spare_samples,
overlaps=header.overlaps,
)


Expand Down Expand Up @@ -361,6 +368,11 @@ def _against_limits(facts: Facts, policy: Policy, fmt: str) -> list[str]:
"the image uses one and the rest are not an alpha channel; the policy does not "
"allow spare samples"
)
if facts.overlaps and not policy.allow_overlapping_tag_data:
reasons.append(
f"a {sniff.describe(fmt)} whose tags claim more data than it holds: "
+ "; ".join(facts.overlaps)
)
return reasons


Expand Down
8 changes: 8 additions & 0 deletions src/sillybos/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def _policy(args: argparse.Namespace) -> Policy:
changes["tiff_tags"] = frozenset(args.tiff_tags.split(","))
if args.inconsistent_tiff_tags:
changes["allow_inconsistent_tiff_tags"] = True
if args.overlapping_tag_data:
changes["allow_overlapping_tag_data"] = True
if args.no_spare_tiff_samples:
changes["allow_spare_tiff_samples"] = False
if args.pdf_features:
Expand Down Expand Up @@ -165,6 +167,12 @@ def build_parser() -> argparse.ArgumentParser:
help="do not refuse a TIFF whose tags contradict each other (a ColorMap of the wrong "
"size, a floating-point Predictor on integer samples)",
)
parser.add_argument(
"--overlapping-tag-data",
action="store_true",
help="do not refuse a file whose tags claim more data between them than it holds "
"(a TIFF's directory, the EXIF block of a JPEG or PNG)",
)
parser.add_argument(
"--no-spare-tiff-samples",
action="store_true",
Expand Down
Loading
Loading