Maruan Sahyoun created PDFBOX-6361:
--------------------------------------
Summary: Limit the work done in nested form XObjects and Type 3
glyphs
Key: PDFBOX-6361
URL: https://issues.apache.org/jira/browse/PDFBOX-6361
Project: PDFBox
Issue Type: Bug
Reporter: Maruan Sahyoun
Form XObjects and Type 3 glyph procedures can call other forms or glyphs, and
`PDFStreamEngine` limits how deep these calls can be nested (50 levels). The
depth limit doesn't bound the total work, though: if every level calls the next
one several times, the number of executed streams grows exponentially. A form
that draws the next form four times, nested 20 levels deep, results in about
10^12 stream executions; a Type 3 glyph that shows two glyphs of its own font
runs about 2^50 times before the depth limit stops it. A document of a few
kilobytes then blocks rendering (Type 3 glyphs and forms) or text extraction
(forms) of that page indefinitely, and the thread can't be interrupted.
Found by a Claude security scan.
Proposed change
- Count the operators executed per page in nested streams, i.e. in forms or
Type 3 glyphs that are called from within another form or glyph. Forms and
glyphs called directly from the page content are not counted.
- Allow nested streams to execute up to 100 times as many operators as are
executed at the levels above them, but at least 10,000,000, so that large
documents with many forms aren't affected.
- When the limit is reached, skip the remaining nested streams of that page
and log one error, like the existing depth limit does.
- Keep the existing depth limit unchanged.
- Add regression tests for a chain of Type 3 fonts and a chain of form
XObjects.
Claude on behalf of Maruan Sahyoun (msahyoun)
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]