From 6166eba5f1813dcb22541a5dd54fb3d09d460a09 Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 20 Oct 2026 21:03:55 +0200 Subject: [PATCH] =?UTF-8?q?docs(docs):=20PDF=5FIMPORT=5FHARDENING=20=C2=A7?= =?UTF-8?q?6=20classifies=20every=20open=20import=20risk=20of=20=C2=A75=20?= =?UTF-8?q?and=20BDR-058/059/063=20(fixed=20with=20proof,=20accepted=20tem?= =?UTF-8?q?porarily,=20blocking=20before=20merge,=20before=20public=20expo?= =?UTF-8?q?sure)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/development/PDF_IMPORT_HARDENING.md | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/development/PDF_IMPORT_HARDENING.md b/docs/development/PDF_IMPORT_HARDENING.md index 8b3a0f0e..83995d6a 100644 --- a/docs/development/PDF_IMPORT_HARDENING.md +++ b/docs/development/PDF_IMPORT_HARDENING.md @@ -125,3 +125,41 @@ hides its `/Keywords`, so a stripped attachment on such a file reads as that reader: still open for the PDF path), the decoder memory envelope of PNG logos (bounded by the 4096² cap, about 430 MB worst case for four logos). + +## 6. R4.9 classification (2026-10-20, `feature/rust-r4-pdf-core`, before the merge) + +Every open point of §5 and of the R4 decisions BDR-058, BDR-059 and BDR-063, +in one of four classes: **fixed with proof** (a test or a measure in the +repository), **accepted temporarily** (bounded, with the justification and +what closes it), **blocking before merge** (the owner's own gate), **before +public exposure** (or before the upload it concerns is activated). The +validated refusals of hostile files stay as they are: no cap, threshold or +message was relaxed at R4.9, and no path rewrites, drops or alters a user's +file, draft or archive on an error (the file is read through the File API +only; a refused import leaves the tab's texts in place: app suites +`routes.HomeRoute.*`, `routes.coreStopped`, `state.coreFailures`). + +| # | Point | Origin | Class | Proof, justification, or what closes it | +|---|---|---|---|---| +| 1 | PDF object graph parsed by pdf-lib on untrusted input (the 1000:1 object-stream expansion, §1) | §5 item 1 | fixed with proof | no PDF library left (R4.8): the Rust byte scanner locates the attachment (`crates/core/src/pdf/read/probe.rs`), cargo `pdf_scan`, `pdf_robustness`; `apps/app/tests/unit/r4.census.test.ts` fails on a return of pdf-lib or a TypeScript scanner | +| 2 | Inflation bound and the hostile classes (bombs, 32 candidates, token-dense 16 MiB, nested copies) | §5 item 2, BDR-058 | fixed with proof | one 16 MiB budget shared by the candidates, `MAX_JSON_VALUES` 400,000, depth 64, `--max-memory` 1 GiB trap; cargo `pdf_budget`, `pdf_inflate`, `pdf_json_js`; the browser run of the classes (RUST.md §10.4, three engines: ≤ 68 MiB of linear memory, the tab alive) | +| 3 | The same classes on the owner's devices (iPhone, low-end Android) | BDR-058, BDR-060, plan OD-6 | blocking before merge | J1.2, J1.10 on the iPhone and the Android phone (`R4_J1.md`); the computer run of 2026-10-18 passed with no failure; a device not run stays NON TESTÉ | +| 4 | The 1 GiB module ceiling is a safety net, not a tab guarantee | BDR-058 | accepted temporarily | documented as such (RUST.md §10.3); the worker is terminated on timeout or crash, so the main instance never holds the hostile tree; closes with the device run (J1.9, J1.10: no reload, no memory warning) | +| 5 | WebKit, a 50 MiB file: 145 MiB of content growth against 76 for the deleted TypeScript reader | BDR-059 | accepted temporarily | the owner kept the 50 MiB cap and refused a streaming scanner at R4.3; the worker reads the file in 1 MiB chunks into linear memory (one copy; the 324 MiB worker-read figure is gone); closes with J1.8 on the iPhone (the tab survives, time noted) or a later streaming scanner | +| 6 | WebKit leak criterion (≤ 10 MiB recurring over ≥ 5 imports) not demonstrable headless | BDR-058, BDR-059 | accepted temporarily | headless WebKit has no forced GC; the one-page series levels off and a no-import control grows the same way with navigation (RUST.md §10.5); closes with J1.9 on the iPhone (six L imports, no reload) | +| 7 | Chromium per-export RSS growth ≈ 20 MiB on L (R4.6, same figures in the TypeScript control, plateau after 8) | BDR-063 | see RUST.md §10.11 | the R4.9 memory bench (`scripts/browser/r4-memory-bench.mjs`) separates the module's linear memory, the renderer RSS, the live canvases / images / blobs / object URLs, the transient peak and the four rest windows; verdict and class in RUST.md §10.11, row kept here for the register | +| 8 | A hidden tab pauses the task timer: a hostile file keeps the worker busy in the background | RUST.md §10.5 | accepted temporarily | by design (plan §B.1.5 item 3: a phone that switches apps must not lose a legitimate import); the core's own bounds (item 2) cap the work; the worker dies with the tab | +| 9 | Timers (10 s start, 20 s task) are hypotheses | RUST.md §10.5, plan §B.3 | blocking before merge | J1.12 on each device gives the slowest legitimate import; the rule (≥ 10 × that) confirms or moves the value before the merge | +| 10 | OD-4: an overwritten duplicate key holding a lone surrogate escape is refused where JSON.stringify once dropped it | BDR-057, BDR-058 | fixed with proof | declared (plan §A.3), refused with `error_lone_surrogate`, the file untouched; cargo `pdf_import` (O8 declared rows), app `routes.HomeRoute.messages`; no Faunosteo build writes duplicate keys | +| 11 | Worker crash, timeout and resource overflow told apart from a corrupt file | BDR-058, OD-5 | fixed with proof | closed outcome kinds (`core/worker/outcome.ts`), messages pinned by `routes.HomeRoute.import` and `routes.HomeRoute.rescueCopy`; a technical failure never says the PDF is not a Faunosteo file | +| 12 | Report collection caps on read (observations, zones, findings per observation) | §5 item "collection caps" | before public exposure | out of R4 (plan A11); today bounded by `MAX_JSON_VALUES` (400,000 values, 10 × the CAP envelope of 500 observations: a report of about 5,000 observations at the CAP density at most) and by the export's caps (500 × 8 views, closed kind); a dense hostile report slows the editor but cannot exhaust it | +| 13 | `` nesting and reference budget on the PDF path | §5 "remaining low findings" | fixed with proof | every SVG the export composes went through the core's one reader (R3: cycles refused, expansion > 50,000 elements refused, prescan caps); `ExportInput` runs `read_svg` per asset (R4.4); cargo `svg_sanitiser`, `pdf_layout` | +| 14 | PNG logo decoder envelope (4096² cap, four logos) | §5 "remaining low findings" | fixed with proof | the application exports the bundled logos only (`src/assets/brand`, never the archive's branding: `export_from_envelope` is cargo-only); the gate refuses above 8192 px a side, 4096² pixels or 16 MiB of raw scanlines before any allocation (`PNG_MAX_*`, cargo `pdf_png` 108 cases + budget cases); the session frees the planes at `add_raster` | +| 15 | Option C or a server-side import for any path that still parses PDF objects | §5 item 4 | before public exposure | no such path exists today; applies to Step 14 if a server-side reader is introduced | +| 16 | pdf-lib (unmaintained since 2021) | §5 item 5 | fixed with proof | left the repository at R4.8; `r4.census` | +| 17 | Stamped PDFs saved with object streams (before Step 6) read a stripped attachment as `no_attachment` | §4 trade-off | accepted temporarily | pre-Step-6 files only, same outcome as a foreign PDF, no data at stake; documented in PDF-FORMAT | +| 18 | Imports offered to external users | §5 gate | before public exposure | the gate stays closed: the import is a local-tool feature; opening it needs items 3, 9 and 12 closed and a fresh audit of the worker path | + +Owner reading at the R4.9 checkpoint: no item in this table is a code +change pending in R4; items 3 and 9 are the device run (J1), items 12, 15 and +18 are the public-exposure gate, item 7 is answered by the bench.