Skip to content

feat: a policy on the codecs a PDF's images may use, found by filter name - #15

Merged
stephen-masters merged 2 commits into
mainfrom
feat/pdf-image-codecs
Nov 3, 2026
Merged

stephen-masters merged 2 commits into
mainfrom
feat/pdf-image-codecs

Conversation

@stephen-masters

Copy link
Copy Markdown
Contributor

Summary

  • Policy.pdf_image_codecs: which of JPEG, JPEG 2000, JBIG2 and CCITT a PDF's images may be coded with. Both presets allow all four, since scanners and the archives that derive PDFs from scans write them (five of the seven PDFs in Tetrak OCR's corpus are JBIG2-coded). A policy that knows its source never writes one refuses it by name: sillybos --pdf-image-codecs jpeg,jpx,ccitt. A feat, not a feat!: nothing that passed before is refused by default.
  • Found by the filter's name in the bytes, in the same bounded pass as the launch-action scan. pdfimages -list was the obvious tool and is deliberately not used: it opens a JPX stream with OpenJPEG just to describe it, which is the decoder code the check exists to keep from the file (CVE-2025-54874 is in exactly that header reader). The blind spot is the same as the launch action's: a filter named only through an indirect reference inside a compressed object stream. README, AGENTS.md and the advisories guide say so.
  • The name scan now matches an escaped digit, so /JBIG#32Decode is seen.
  • Proposals: the three JBIG2 records name the field and its test and can be promoted after a reading; the six on embedded fonts move to C, because every searchable PDF embeds a font (all thirty-eight PDFs in the Tetrak checkouts do, Tetrak OCR's own output included), so a policy refusing fonts would refuse the text layers it exists to protect.
  • Promoted CVE-2025-9900 into the record, now that max_side (4.0.0) holds every side and the record names its test.

Test plan

  • ruff, mypy, pytest with the coverage floor: 400 passed
  • uv lock --check; zensical build --clean --strict
  • sillybos over the seven corpus PDFs: all pass by default; with --pdf-image-codecs jpeg,jpx,ccitt the five JBIG2 ones are refused with the reason, the other two pass
  • scripts/advisory_record.py proposals lists no complaints

🤖 Generated with Claude Code

stephen-masters and others added 2 commits November 2, 2026 23:34
…name

`pdf_image_codecs` names which of JPEG, JPEG 2000, JBIG2 and CCITT a
PDF's images may be coded with. Both presets allow all four: scanners
and the archives that derive PDFs from scans write them, and five of the
seven PDFs in Tetrak OCR's corpus are JBIG2-coded. A policy that knows
its source never writes one refuses it by name.

The codec is found by the filter's name in the bytes, the way a launch
action is, because `pdfimages -list` opens a JPX stream with OpenJPEG
just to describe it, which is the decoder's code the check exists to
keep from the file. The name scan now also matches an escaped digit, so
`/JBIG#32Decode` is seen.

The three JBIG2 proposals name the field and its test; the six on
embedded fonts move to C, since every searchable PDF embeds a font and
a policy refusing them would refuse the text layers it exists to protect.

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…y side

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@stephen-masters
stephen-masters merged commit b34257d into main Nov 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant