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
13 changes: 8 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ code touches it. So:
`sillybos/pillow.py`, which is the optional extra.
- A PDF is asked about through `pdfinfo` and `pdfdetach` in a subprocess
with a timeout. Never add a PDF parser as a dependency, and never read a
PDF's objects with code here. The one thing this code does read from a
PDF's bytes is the *name* of a launch action, by a bounded search for
its spelling (`pdf.py`, `_has_launch_action`), because no poppler tool
reports one; a search for bytes is not a parser, and it must stay that
way.
PDF's objects with code here. The only things this code reads from a
PDF's bytes are *names*, by a bounded search for their spellings
(`pdf.py`, `_names_in`): a launch action, because no poppler tool
reports one, and the filters its images are coded with (DCT, JPX, JBIG2,
CCITT), because the tool that would list them, `pdfimages -list`, opens
a JPX stream with OpenJPEG just to describe it. A search for bytes is
not a parser, and it must stay that way; never add `pdfimages` to the
tools the check runs.
- The library has **no runtime dependencies**, and `[project] dependencies`
stays `[]`. Everything else goes in an extra.
- Every read of a file is bounded by a constant or by the policy, and every
Expand Down
14 changes: 10 additions & 4 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) |
| `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 |
| `pdf_image_codecs` | jpeg, jpx, jbig2, ccitt | the same | Which codecs a PDF's images may be coded with: JPEG, JPEG 2000 (OpenJPEG), JBIG2 and CCITT fax. Each hands the stream to a decoder of its own inside poppler, and the JBIG2 decoder is where several of its flaws have been (CVE-2025-32365, CVE-2026-93312, CVE-2026-93313). Scanners and the archives that derive PDFs from scans write all four, so both presets allow them; refuse one only when you know your source never writes it. Found by the filter's name in the file, not by `pdfimages -list`, which opens a JPX stream with OpenJPEG just to describe it |
| `pdfinfo_timeout` | 30 s | 30 s | How long `pdfinfo` may take before the file is refused |

The defaults were set from a real corpus of archival scans (largest page 39
Expand Down Expand Up @@ -187,8 +188,9 @@ prints one object per line for a pipeline; `-q` prints only refusals.
`pdfinfo` reports the page count, whether it is encrypted, whether it
carries JavaScript or a form and, if the count is within the limit,
every page's size; `pdfdetach` reports attached files; and a bounded
scan of the bytes finds the name of a launch action, and of JavaScript
that an older poppler does not report, with the `#xx` escapes a name
scan of the bytes finds the name of a launch action, of JavaScript
that an older poppler does not report, and of the filters its images
are coded with (DCT, JPX, JBIG2, CCITT), with the `#xx` escapes a name
may hide behind undone.
5. **The limits**, against what the header said.

Expand All @@ -213,8 +215,12 @@ Say this plainly, because a security library carries an implied promise.
- **It does not look inside a PDF beyond what `pdfinfo` reports.** A PDF's
structure cannot be read from a fixed header; it has to be parsed, and
the parser this library trusts is poppler's, in its own process, with a
timeout. Checks for JavaScript, launch actions, embedded files and forms
(things a scanned book never has) are the next step.
timeout. JavaScript, launch actions, embedded files, forms and the
codecs of its images are found from that report and from names in the
bytes; a name reachable only through an indirect reference inside a
compressed object stream is not seen. `pdfimages -list` would see it,
but it opens a JPEG 2000 stream with OpenJPEG just to describe it, so
this library never runs it.
- **It does not validate uploads.** File names, path traversal and zip
bombs belong to a web framework's upload handling. This library starts
after the file is on disk and asks only whether a decoder may open it.
Expand Down
17 changes: 10 additions & 7 deletions docs/advisories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

sillybos stands in front of decoders it does not control. When one of them
publishes a security advisory, the question for this library is narrow:
**would a bounded header check, or what `pdfinfo`, `pdfimages -list` or
`pdffonts` report, have kept the triggering file from the decoder?** A
**would a bounded header check, what `pdfinfo` reports, or a name found
in a PDF's bytes have kept the triggering file from the decoder?** A
weekly job fetches the advisories and opens an issue for each; a
maintainer answers that question and files the issue in a bucket. This
page is the procedure.
Expand Down Expand Up @@ -136,10 +136,13 @@ bucket and the sentence are right, promote it, and if not, edit the file
first. A proposal in bucket A, B or B2 cannot be promoted until it names a
test that builds the triggering file and checks it is refused: for an A
that test usually exists already, and for a B or B2 the policy field and
the corpus case come first, as the next section says. The proposals in
B2 at the time of writing all want one of two coarse PDF policies, on
embedded fonts and on JBIG2 image streams, and the one B wants a ceiling
on a single image dimension.
the corpus case come first, as the next section says. The B2 proposals on
JBIG2 streams name `pdf_image_codecs`, which came out of them; the ones on
embedded fonts were moved to C, because every searchable PDF embeds a
font, so a policy refusing fonts would refuse the text layers it exists to
protect. `pdfimages -list` was found to open a JPX stream with OpenJPEG
just to describe it, which is why the codecs are found by name and that
tool is never run.

## The buckets

Expand All @@ -150,7 +153,7 @@ answer to the question at the top of this page.
|---|---|---|
| **A** | Already refused by an existing check: a format outside the four, a frame coding the policy refuses, a size over a limit | Say which check, and close |
| **B** | Preventable from a header field our readers can see: a marker, a tag, a chunk, a count, a dimension | A policy field and a hostile corpus case (below), then close when it ships |
| **B2** | Preventable only by a coarse policy on a PDF's contents that `pdfimages -list` or `pdffonts` report: a JBIG2 or JPX stream, an embedded font | The same as B, through the PDF path; note that the policy will be coarse |
| **B2** | Preventable only by a coarse policy on a PDF's contents: the codec of an image, found by its filter's name in the bytes (`pdf_image_codecs`). Not an embedded font: every searchable PDF carries one, so a policy on fonts has no user, and a flaw in the font program is C | The same as B, through the PDF path; note that the policy will be coarse |
| **C** | Needs decoding to detect: a flaw in the pixel data, the entropy-coded segment, the font program | Out of this library's reach by design; say so and close. Updating the decoder is the fix |
| **D** | Reaches `pdfinfo` itself | Check that the check still fails closed (a timeout or a non-zero exit is a refusal), and close |
| **N** | Not reached by opening a file: a command-line tool, a save or encode path, a drawing or font API, a parser that only runs on append | Close |
Expand Down
8 changes: 4 additions & 4 deletions docs/advisories/proposed/CVE-2025-27363.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"fixed": "2.13.1",
"reached_by": "open",
"trigger": "Rendering a PDF whose embedded font is a TrueType GX or variable font with crafted subglyph structures; FreeType parses the font when poppler draws the text.",
"bucket": "B2",
"finding": "Reached by rendering, through the embedded font. pdffonts reports every embedded font and its type, so a coarse policy refusing embedded fonts, or TrueType fonts, would keep the font from FreeType; a scanned book has no fonts, but a searchable PDF's invisible text layer does, so the policy would be a trade. Not built.",
"bucket": "C",
"finding": "Reached by rendering, through the embedded font. pdffonts reports every embedded font and its type, so a coarse policy refusing embedded fonts, or TrueType fonts, would keep the font from FreeType; a scanned book has no fonts, but a searchable PDF's invisible text layer does, so the policy would be a trade. No policy is built: every searchable PDF embeds a font, Tetrak OCR's own output included (all thirty-eight PDFs in its checkouts carry one), so a policy refusing fonts would refuse the text layers it exists to protect. A flaw in the font program is out of this library's reach; the boxed process is the defence.",
"refusal": null,
"verified_by": [],
"protect": {
"general": "Upgrade to FreeType 2.13.1.",
"specific": "Until a policy on embedded fonts exists, render in a boxed process; a PDF with no text layer carries no font for FreeType to parse."
"specific": "Render in a boxed process; a PDF with no text layer carries no font for FreeType to parse."
},
"sources": [
"https://osv.dev/vulnerability/DEBIAN-CVE-2025-27363"
],
"triaged": "2026-11-01",
"checked": "2026-11-01",
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person."
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person. Moved from B2 to C on 2026-11-02, with the finding above."
}
16 changes: 11 additions & 5 deletions docs/advisories/proposed/CVE-2025-32365.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@
"reached_by": "open",
"trigger": "Rendering a PDF page whose image is a crafted JBIG2 stream.",
"bucket": "B2",
"finding": "pdfimages -list reports each image stream's encoding, so a coarse policy refusing JBIG2 streams would keep the stream from the decoder. Some scanners write JBIG2-compressed PDFs, so the policy would refuse real scans too. Not built.",
"refusal": null,
"verified_by": [],
"finding": "Reached by rendering a page whose image is a JBIG2 stream. The image's filter is named in its stream dictionary, which cannot be hidden inside a compressed object stream, so a bounded search of the bytes finds /JBIG2Decode and the policy can refuse the codec by name (pdf_image_codecs). The default allows it: scanners and the archives that derive PDFs from scans write JBIG2 (five of the seven PDFs in Tetrak OCR's corpus). pdfimages -list would report the codec too, but it opens a JPX stream with OpenJPEG just to describe it, so the library does not run it.",
"refusal": {
"check": "pdf_image_codecs",
"default": false,
"setting": "Policy(pdf_image_codecs={\"jpeg\", \"jpx\", \"ccitt\"})"
},
"verified_by": [
"tests/test_check.py::TestPdf::test_a_jbig2_pdf_under_a_policy_that_refuses_it"
],
"protect": {
"general": "Upgrade to poppler 25.04.0.",
"specific": "Until a policy on image stream encodings exists, render in a boxed process."
"specific": "If nothing you handle is JBIG2-coded, say so in the policy: sillybos --pdf-image-codecs jpeg,jpx,ccitt. Otherwise render in a boxed process."
},
"sources": [
"https://osv.dev/vulnerability/DEBIAN-CVE-2025-32365"
],
"triaged": "2026-11-01",
"checked": "2026-11-01",
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person."
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person. The policy field was named on 2026-11-02."
}
8 changes: 4 additions & 4 deletions docs/advisories/proposed/CVE-2026-102620.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"fixed": null,
"reached_by": "open",
"trigger": "Rendering a PDF whose embedded TrueType font makes FoFiTrueType::cvtSfnts overflow.",
"bucket": "B2",
"finding": "Reached through an embedded font that pdffonts would report; as CVE-2026-93314. Not built.",
"bucket": "C",
"finding": "Reached through an embedded font that pdffonts would report; as CVE-2026-93314. No policy is built: every searchable PDF embeds a font, Tetrak OCR's own output included (all thirty-eight PDFs in its checkouts carry one), so a policy refusing fonts would refuse the text layers it exists to protect. A flaw in the font program is out of this library's reach; the boxed process is the defence.",
"refusal": null,
"verified_by": [],
"protect": {
"general": "Upgrade poppler to a version that has the fix; the upstream record names it.",
"specific": "Until a policy on embedded fonts exists, render in a boxed process."
"specific": "Render in a boxed process."
},
"sources": [
"https://osv.dev/vulnerability/DEBIAN-CVE-2026-102620"
],
"triaged": "2026-11-01",
"checked": "2026-11-01",
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person."
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person. Moved from B2 to C on 2026-11-02, with the finding above."
}
8 changes: 4 additions & 4 deletions docs/advisories/proposed/CVE-2026-23865.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"fixed": "2.14.2",
"reached_by": "open",
"trigger": "Rendering a PDF whose embedded OpenType variable font carries crafted HVAR, VVAR or MVAR tables.",
"bucket": "B2",
"finding": "Reached by rendering, through an embedded font that pdffonts would report; as CVE-2025-27363, a coarse policy on embedded fonts would keep it from FreeType, at the cost of refusing searchable PDFs' text layers. Not built.",
"bucket": "C",
"finding": "Reached by rendering, through an embedded font that pdffonts would report; as CVE-2025-27363, a coarse policy on embedded fonts would keep it from FreeType, at the cost of refusing searchable PDFs' text layers. No policy is built: every searchable PDF embeds a font, Tetrak OCR's own output included (all thirty-eight PDFs in its checkouts carry one), so a policy refusing fonts would refuse the text layers it exists to protect. A flaw in the font program is out of this library's reach; the boxed process is the defence.",
"refusal": null,
"verified_by": [],
"protect": {
"general": "Upgrade to FreeType 2.14.2.",
"specific": "Until a policy on embedded fonts exists, render in a boxed process; an image-only PDF carries no font."
"specific": "Render in a boxed process; an image-only PDF carries no font."
},
"sources": [
"https://osv.dev/vulnerability/DEBIAN-CVE-2026-23865"
],
"triaged": "2026-11-01",
"checked": "2026-11-01",
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person."
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person. Moved from B2 to C on 2026-11-02, with the finding above."
}
8 changes: 4 additions & 4 deletions docs/advisories/proposed/CVE-2026-50811.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"fixed": null,
"reached_by": "open",
"trigger": "Rendering a PDF whose embedded variable font makes FreeType call TT_Get_Var_Design with crafted data.",
"bucket": "B2",
"finding": "Reached through an embedded variable font that pdffonts would report; a coarse policy on embedded fonts would keep it from FreeType. Not built.",
"bucket": "C",
"finding": "Reached through an embedded variable font that pdffonts would report; a coarse policy on embedded fonts would keep it from FreeType. No policy is built: every searchable PDF embeds a font, Tetrak OCR's own output included (all thirty-eight PDFs in its checkouts carry one), so a policy refusing fonts would refuse the text layers it exists to protect. A flaw in the font program is out of this library's reach; the boxed process is the defence.",
"refusal": null,
"verified_by": [],
"protect": {
"general": "Upgrade FreeType to a version that has the fix; the upstream record names it.",
"specific": "Until a policy on embedded fonts exists, render in a boxed process."
"specific": "Render in a boxed process."
},
"sources": [
"https://osv.dev/vulnerability/DEBIAN-CVE-2026-50811"
],
"triaged": "2026-11-01",
"checked": "2026-11-01",
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person."
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person. Moved from B2 to C on 2026-11-02, with the finding above."
}
16 changes: 11 additions & 5 deletions docs/advisories/proposed/CVE-2026-93312.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@
"reached_by": "open",
"trigger": "Rendering a PDF page whose image is a crafted JBIG2 stream.",
"bucket": "B2",
"finding": "A JBIG2 stream, which pdfimages -list reports; a coarse policy refusing JBIG2 would keep it from the decoder, at the cost of refusing scanners that write JBIG2. Not built.",
"refusal": null,
"verified_by": [],
"finding": "Reached by rendering a page whose image is a JBIG2 stream. The image's filter is named in its stream dictionary, which cannot be hidden inside a compressed object stream, so a bounded search of the bytes finds /JBIG2Decode and the policy can refuse the codec by name (pdf_image_codecs). The default allows it: scanners and the archives that derive PDFs from scans write JBIG2 (five of the seven PDFs in Tetrak OCR's corpus). pdfimages -list would report the codec too, but it opens a JPX stream with OpenJPEG just to describe it, so the library does not run it.",
"refusal": {
"check": "pdf_image_codecs",
"default": false,
"setting": "Policy(pdf_image_codecs={\"jpeg\", \"jpx\", \"ccitt\"})"
},
"verified_by": [
"tests/test_check.py::TestPdf::test_a_jbig2_pdf_under_a_policy_that_refuses_it"
],
"protect": {
"general": "Upgrade to poppler 26.08.0.",
"specific": "Until a policy on image stream encodings exists, render in a boxed process."
"specific": "If nothing you handle is JBIG2-coded, say so in the policy: sillybos --pdf-image-codecs jpeg,jpx,ccitt. Otherwise render in a boxed process."
},
"sources": [
"https://osv.dev/vulnerability/DEBIAN-CVE-2026-93312"
],
"triaged": "2026-11-01",
"checked": "2026-11-01",
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person."
"notes": "Proposed from the advisory's text on 2026-11-01, as part of folding the backfill into the record; not yet confirmed by a person. The policy field was named on 2026-11-02."
}
Loading
Loading