[ 
https://issues.apache.org/jira/browse/PDFBOX-6361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154463#comment-18154463
 ] 

ASF subversion and git services commented on PDFBOX-6361:
---------------------------------------------------------

Commit 1941172 from Maruan Sahyoun in branch 'pdfbox/branches/3.0'
[ https://svn.apache.org/r1941172 ]

PDFBOX-6361: limit the operators executed in nested form XObjects and Type 3 
glyphs per page

Co-Authored-By: Claude <[email protected]>

> 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
>    Affects Versions: 2.0.37, 3.0.8 PDFBox, 4.0.0
>            Reporter: Maruan Sahyoun
>            Assignee: Maruan Sahyoun
>            Priority: Major
>             Fix For: 2.0.38, 3.0.9 PDFBox, 4.0.0
>
>
> 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]

Reply via email to