fix(pdf): PNG chunk allowlist and mandatory empty IEND — text and profile chunks refused (UPNG nextZero spin)

This commit is contained in:
bchanot committed 2026-10-11 14:29:56 +02:00
1 parent 3a26c61119
commit 0ceb357b18
3 files changed
+129 -34

No files matched your search

+12 -5
View File
@@ -162,7 +162,7 @@ Two operations are distinct:
| snapshot document | ≤ 64 views, ≤ 1,024 annotations, ≤ 8,192 finding nodes, depth ≤ 8, names ≤ 512 chars |
| branding | PNG base64 ≤ 512 KiB, SVG ≤ 256 KiB, http(s) URLs ≤ 2,048 chars |
| branding URL | `http(s)://` then printable ASCII only, without `"` `'` `(` `)` `<` `>` `\`, no space or control character |
| branding PNG | valid signature, one IHDR (13 bytes) first, no second IHDR or APNG chunk (`acTL`, `fcTL`, `fdAT`), no chunk past the buffer, each side ≤ 8,192 px, ≤ 16,777,216 px (4096²) |
| branding PNG | valid signature, one IHDR (13 bytes) first, then only `PLTE` `tRNS` `IDAT` `gAMA` `cHRM` `sRGB` `sBIT` `pHYs` `bKGD`, no chunk past the buffer, an empty `IEND` as the last bytes, each side ≤ 8,192 px, ≤ 16,777,216 px (4096²) |
| report at export | ≤ 500 observations, ≤ 8 views per observation |
| SVG sanitiser | ≤ 20,000 elements, nesting ≤ 64, ≤ 256 `<use>`, blur `stdDeviation` ≤ 100 |
@@ -189,10 +189,17 @@ drawn), even from an archive that passed the reader. The URI itself is the
hex form of the URL's ASCII bytes (`<68747470…>`), not UTF-16 with a BOM,
so readers that take `/URI` as raw bytes (poppler) follow it. A PNG logo is
checked before decoding: the signature and a first 13-byte IHDR, then the
chunk list is walked to `IEND`; a second IHDR (the decoder would size its
buffer from the last one), an APNG chunk, a chunk length past the end of
the buffer or a header over the pixel budget refuses the slot. That slot
alone prints its fallback text and the export reports `logo_failed`.
chunk list is walked and must end on an empty `IEND` that closes the file.
Only the chunk types the decoder reads by fixed offsets or by declared
length are accepted (`PLTE`, `tRNS`, `IDAT`, `IEND`, `gAMA`, `cHRM`, `sRGB`,
`sBIT`, `pHYs`, `bKGD`); a second IHDR (the decoder would size its buffer
from the last one), an APNG chunk, a text or profile chunk (`tEXt`, `iTXt`,
`zTXt`, `iCCP`: the decoder scans them for a NUL byte and never stops when
none follows in the buffer), an unknown type, a chunk length past the end
of the buffer, a missing IEND or bytes after it, or a header over the pixel
budget refuses the slot. The archive accepts only PNGs ending on IEND, even
though the decoder reads a PNG without one. That slot alone prints its
fallback text and the export reports `logo_failed`.
### Known limits