chore(memory): BDR-052, BDR-053, LRN-056, EVAL-022 (R2 maintenance, R3)

This commit is contained in:
bchanot committed 2026-10-15 00:43:11 +02:00
1 parent 23895b9351
commit 0dc49debc4
3 files changed
+29

No files matched your search

+10
View File
@@ -426,3 +426,13 @@ Apply: R3/R4/R5 ports (same oracle stack), any wasm loaded by Vite, any agent fa
Context: R2 rewrote lone surrogate escapes to U+FFFD before serde_json so JS-era texts still parsed (L1). Owner refused: silent change of historical data. Fix: drop pre-pass; serde_json already refuses; scan text only after failure to name kind (zero cost on valid input, exact refusal kind for UI message + quarantine). Trap found by fix: oracle file freezing TS outputs carried lone escapes → whole-file parse failed; test loader must spell escapes out as literal text (evidence kept), never re-normalise. Also: `u32::from_str_radix` accepts leading `+` → escape scanner checks hex digits explicitly.
Apply: any reader of user data (R3 SVG, R4 PDF reader, R5 pipeline) → refuse with closed kind + keep original, never repair silently; a leniency step needs explicit owner decision and declared-difference test.
## LRN-056 | 2026-10-15 | XML parser recursion, prescan closers, URL/CSS whitespace: three traps porting an SVG sanitiser
- roxmltree 0.21.1 recurses per nesting level (parse_element ↔ parse_content); 1 MiB wasm stack overflows between 1,000 and 3,000 levels; nodes_limit checked too late. Measure parser depth on the real stack size before trusting "iterative" claims (plan rev 1 said iterative: false). Fix = own markup prescan before any parse; fixed release only in unreleased git.
- A prescan must search each closer AFTER its whole opener (`-->` from +4, `]]>` from +9, `?>` from +2): searching from +1 let `<!-->` desync scanner vs XML grammar and hide 5,000 levels (security audit MEDIUM). Prove with differential fuzz vs the real parser (auditor ran ~4M docs) + calibrated small-stack run.
- Locality of `href` / `url(#…)` must follow the browser's parsers: URL parser strips only C0+space, CSS tokenizer only space/tab/newline. JS `trim()`/`\s` include NBSP/ideographic/BOM → `\u00A0#a` passes as local, resolves as relative URL. TS engine has the same flaw (declared difference).
- Mutation checks on oracle tests find blind spots: namespace check mutant passed until a rebound-prefix corpus case was added.
- vitest/React: effect with per-render deps (useT closure) + setState(new array) → infinite render loop (OOM); guard side-effectful restore per attempt with a ref.
- Visual parity: freeze happy-dom trees + Chromium screenshots BEFORE switch; same-build double capture gives the noise floor (30/30 identical); synthetic controls validate the comparator; baseline = `git archive develop` built in scratchpad (no worktree).
Apply: R4 PDF reader/writer (byte scanners, inflate), Step 13 uploads (reader in worker child), any parser fed untrusted input.