Maruan Sahyoun created PDFBOX-6370:
--------------------------------------
Summary: Limit the number of mappings in cmap subtables
Key: PDFBOX-6370
URL: https://issues.apache.org/jira/browse/PDFBOX-6370
Project: PDFBox
Issue Type: Bug
Components: FontBox
Reporter: Maruan Sahyoun
Assignee: Maruan Sahyoun
Several cmap subtable formats map ranges of character codes: format 4 has
segments, formats 8, 12 and 13 have groups, format 2 has subheaders. The ranges
are expanded into one mapping per character code when the font is read. Sorted,
non-overlapping ranges, as the specification requires, map each code at most
once. But the ranges are not checked for overlap. A small font could contain
many ranges that each cover a large part of the code space again, e.g. format
13 groups `0..E`, `0..E+1`, `0..E+2`, ... Each 12-byte group then adds up to
1,114,112 map operations. This happens when an embedded font is loaded, i.e.
when a document is opened.
In 2.0, the check for unsorted format 13 groups was inside the loop over the
codes of a group. Only the first code of each group was mapped, and a warning
was logged for every further code.
Proposed change
- Limit the mappings of a cmap subtable (formats 2, 4, 8, 12 and 13) to the
number of character codes (0x110000), summed over all its ranges
- If a subtable has more, log a warning and ignore the remaining ranges,
keeping the mappings read so far
- 2.0: check for unsorted format 13 groups once per group, as in 3.0 and trunk
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]