fix(anatomy): url() locality skips CSS whitespace only (security audit R3 pass 2)

This commit is contained in:
bchanot committed 2026-10-15 00:40:30 +02:00
1 parent 157c854ed1
commit 23895b9351
6 files changed
+90 -10

No files matched your search

@@ -11,6 +11,7 @@ Migrate the anatomy core to Rust (review R3 scope): SVG analysis, anatomical tre
- `apps/app/tests/unit/canvas.trees.test.ts` is renamed to `.tsx` (it now mounts the canvas): a rename, no test deleted.
- The sanitiser oracle (`oracles/r3/sanitiser.json`) was regenerated as corpus files were added; the TypeScript it runs (`packages/pdf/src`, `packages/anatomy/src`) is unchanged on the branch (criterion 4), so every regeneration is the same TypeScript's verdict. `highlight.json` gained `edgeDocument` only; its cases and sanitised trees are unchanged since d1aa35e (criterion 4).
- Pass 2 (after the security audit, PASS + 1 MEDIUM + 2 LOW): the prescan searches each closer after its whole opener (`<!-->` desync), `href` locality on ASCII-trimmed text only, root `transform`/`filter`/`mask`/`clip-path` removed; 5 corpus files added (41), the wasm corpus has 49 cases; counts below updated.
- Pass 3 (security pass 2 on the fix: PASS + LOW): `url(` skips CSS whitespace only; corpus 42 files, wasm corpus 50 cases.
- Visual screenshots are uncommitted by design (plan O6); their result is recorded in RUST.md §9.3.
## ACCEPTANCE CRITERIA
@@ -40,10 +41,10 @@ Migrate the anatomy core to Rust (review R3 scope): SVG analysis, anatomical tre
EXPECT: gzip under 600000 bytes / exit 0 / app 352, core-wasm 29, pdf 140, anatomy 131, all passed
9. The hostile corpus runs through the shipped wasm under the stated budgets, and the canvas composes within its own.
CHECK: grep -E "R3 hostile corpus|R3 sheet handle" /tmp/r3-verify-check.log
EXPECT: a hostile-corpus line with 49 cases, slowest under 150 ms, largest growth under 32 MiB; a sheet-handle line with a warm head median under 15 ms
EXPECT: a hostile-corpus line with 50 cases, slowest under 150 ms, largest growth under 32 MiB; a sheet-handle line with a warm head median under 15 ms
10. The hostile corpus covers the owner's classes (scripts, events, external and data references, DTD/entities, depth, element count, `<use>` count, cycles and expansion, malformed, namespaces, CSS, size).
CHECK: ls crates/core/tests/fixtures/svg/hostile | wc -l; ls crates/core/tests/fixtures/svg/hostile | tr '\n' ' '
EXPECT: 41 files including comment-desync-depth, comment-desync-attributes, href-unicode-space, root-presentation, and script, events, script-urls, external-use, data-and-images, external-urls, doctype-entities, malformed, namespaces, css, use-self-cycle, use-mutual-cycle, root-class-style, long-title
EXPECT: 42 files including url-unicode-space, comment-desync-depth, comment-desync-attributes, href-unicode-space, root-presentation, and script, events, script-urls, external-use, data-and-images, external-urls, doctype-entities, malformed, namespaces, css, use-self-cycle, use-mutual-cycle, root-class-style, long-title
11. The docs record the phase: RUST.md §9 (proofs, measurements, differences, risks), CHANGELOG, CLAUDE.md map.
CHECK: grep -c "^## 9. R3" docs/development/RUST.md; grep -c "Rust R3, anatomy core" CHANGELOG.md; grep -c "anatomy/{svg/{prescan,tree,sanitize,refs,number,serialize},layer,compose}" CLAUDE.md
EXPECT: 1 / 1 / 1