[ 
https://issues.apache.org/jira/browse/PDFBOX-6368?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maruan Sahyoun resolved PDFBOX-6368.
------------------------------------
    Resolution: Fixed

> Limit the number of mappings created from bfrange entries in CMaps
> ------------------------------------------------------------------
>
>                 Key: PDFBOX-6368
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6368
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    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
>
>
> `CMapParser` expands each `bfrange` entry into one mapping per code, without 
> limiting the span between the start and end code. With 4-byte codes, a single 
> entry such as `<00000000> <7ffffffe> <0041>` in a CMap of about 50 bytes 
> creates up to 2^31 mappings and causes an `OutOfMemoryError` within about a 
> second. The PDF specification allows at most 256 codes per entry (the start 
> and end code shall differ in the last byte only). In addition, an overflow of 
> the destination value isn't reported when the destination is a single byte, 
> or when all its bytes overflow in non-strict mode, which is used for embedded 
> CMaps; the destination then wraps around to 0 instead of ending the range.
> Found by a Claude security scan.
> Proposed change
>  - Limit the mappings created from a single `bfrange` entry to 65536, which 
> still covers the malformed identity range `<0000> <FFFF> <0000>` supported 
> since PDFBOX-4720.
>  - Limit the mappings created from all `bfrange` entries of a CMap to 262144 
> (4 × 65536), and log a warning once when a limit is reached.
>  - End a range when its destination value overflows completely, also for 
> single byte destinations.
>  - Add regression tests for a huge `bfrange` entry, for many large entries 
> and for a single byte destination, and check that the identity range is still 
> mapped completely.
> 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