Skip to content

reject jobs exceeding XFORM_MAX_PAGES in ipptransform - #194

Open
tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:ipptransform-outpages-overflow
Open

tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:ipptransform-outpages-overflow

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

Out-of-bounds write in prepare_pages on documents with many pages

prepare_pages writes one p.outpages[] entry per output page but never checks the running index against the array's fixed size (XFORM_MAX_PAGES, 10000). The output page count never exceeds the input page count, which is summed from each document's pdfioFileGetNumPages, so a job whose document holds more than 10000 pages walks outpage past the end of the array and writes outpage->pdf and outpage->input[...] out of bounds. ipptransform is the IPP Everywhere transform run on client-submitted documents, through ippeveprinter and directly, so the page count is attacker-controlled.

The check lives in prepare_documents right after the per-document page totals are known, so an oversized job is refused before any layout happens. Jobs up to 10000 pages behave exactly as before.

I could not run make test in my environment (no OpenSSL or GnuTLS available), so I confirmed the write with an AddressSanitizer harness that mirrors the prepare_pages loop over an outpages[XFORM_MAX_PAGES] array (the harness heap-allocates the prepare struct): a 10001-page input reports an out-of-bounds WRITE one element past the array, exactly 10000 pages stays clean, and the new check prevents the overflow.

prepare_pages() walks the fixed-size p.outpages[XFORM_MAX_PAGES] array
without a bounds check, so a document with more than 10000 pages writes
past the end of the array. Reject such jobs in prepare_documents before
laying out pages.

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of input pages is not always the same as the number of output pages - "number-up" and "imposition-template" can map multiple input pages to a single output page, for example.

@michaelrsweet michaelrsweet self-assigned this Oct 23, 2026
@michaelrsweet michaelrsweet added the bug Something isn't working label Oct 23, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants