Repository navigation
feat: a policy on the codecs a PDF's images may use, found by filter name - #15
Merged
Merged
Conversation
…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>
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
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. Afeat, not afeat!: nothing that passed before is refused by default.pdfimages -listwas 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./JBIG#32Decodeis seen.max_side(4.0.0) holds every side and the record names its test.Test plan
uv lock --check;zensical build --clean --strictsillybosover the seven corpus PDFs: all pass by default; with--pdf-image-codecs jpeg,jpx,ccittthe five JBIG2 ones are refused with the reason, the other two passscripts/advisory_record.py proposalslists no complaints🤖 Generated with Claude Code