fix(pdf): inflater fed in 16 KiB slices (browser memory bound), shared 16 MiB candidate budget, monotonic bounded endstream search, JSON object pre-check

This commit is contained in:
bchanot committed 2026-10-11 17:08:56 +02:00
1 parent 6adc38b027
commit 3a6e92625a
6 files changed
+310 -32

No files matched your search

+8
View File
@@ -88,6 +88,14 @@ hides its `/Keywords`, so a stripped attachment on such a file reads as
- Option A merged and the CLI on the scanner; no `PDFDocument.load` on any
untrusted input in the browser.
- A real-browser test of the inflate bound (Chromium, Firefox, Safari): the
vitest suite runs in Node and cannot see a browser inflater's read-ahead.
The audit of 60ee712 measured +2.2 GB RSS in Chromium on a 4 MB / 4 GiB
bomb before the inflater was fed in 16 KiB slices (+215 MB after); that
measurement is manual until a browser runner exists.
- Done: the candidate CPU/byte budget on the scanner, one 16 MiB budget of
examined content shared by every candidate, a monotonic `endstream` search
bounded to the cap, and no JSON parse for a candidate not opening on `{`.
- Option C or a server-side import (Step 14) with a hard memory and time
budget per file, for any path that still parses PDF objects.
- Dependency decision on pdf-lib (unmaintained since 2021): keep it for