Maruan Sahyoun created PDFBOX-6383:
--------------------------------------

             Summary: Limit the preallocated subroutine list of Type 1 fonts
                 Key: PDFBOX-6383
                 URL: https://issues.apache.org/jira/browse/PDFBOX-6383
             Project: PDFBox
          Issue Type: Bug
          Components: FontBox
            Reporter: Maruan Sahyoun


When a Type 1 font is parsed, the subroutine list is filled with as many empty 
entries as the `/Subrs` count in the private dictionary declares, before any 
subroutine is read. The count comes from the font, so a small font declaring 
`/Subrs 2147483647 array` makes the parser try to allocate a list with billions 
of entries, which fails with an `OutOfMemoryError` when the font is loaded.

Each subroutine entry (`dup i n RD ... NP`) takes several bytes, so a font 
can't contain more subroutines than its encrypted binary segment has bytes.

Proposed change
 - Limit the declared `/Subrs` count to the length of the decrypted binary 
segment before allocating the list
 - Log a warning if the count is reduced, and continue parsing

Found by a Claude security scan.

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