fix(anatomy): V1-2.2 review findings, PIs and HTML refused, bounds

Security audit (PASS, 2 MEDIUM, 2 LOW) and verifier (ECARTS 6) on
741c25c: processing instructions and HTML fetchers refused, active
content under a long title classified, linear review groups, full
fixpoint check, bounded preview drawings, missing cap fixtures and
property checks, record wordings.
This commit is contained in:
bchanot committed 2026-10-29 13:38:33 +01:00
1 parent 741c25c464
commit 8294d5471c
15 files changed
+448 -72

No files matched your search

+35 -16
View File
@@ -3874,8 +3874,9 @@ Free (`call`): `sheet.edit` `{document, command}` → `{document}`, failures `un
budget); `sheet.dependents` `{document, key}` → `{dependents: [{element, relation}]}`. Wasm classes: `PreviewBuilder`
(`add_drawing(assetId, sha256, bytes)`, `build(PreviewInput JSON)` throwing `<kind>: <detail>`: `invalid_document`,
`drawing_missing`, `drawing_hash_mismatch`, `fingerprint_mismatch`, `caps`), `PreviewSheet` (`call`: `preview.state`,
`view.canvas`; `replace_document`, `add_drawing`: `{"ok":true}` or `invalid_document`, `drawing_hash_mismatch`,
`read_only`); the function `clean_svg(bytes)` (`SvgCleaning`). `view.canvas` is one composition for `LoadedSheet` and
`view.canvas`; `replace_document`, `add_drawing`: `{"ok":true,"value":null}` or `invalid_document`,
`drawing_hash_mismatch`, `caps`, `read_only`); a preview holds at most 16 drawings of at most 2 MiB each
(`MAX_HELD_DRAWINGS`; the builder's `add_drawing` answers `false` past them and its build throws `caps: drawings`); the function `clean_svg(bytes)` (`SvgCleaning`). `view.canvas` is one composition for `LoadedSheet` and
`PreviewSheet` (`ops::canvas_of`). The runtime (`CoreRuntime`) does not manage preview handles yet: their poison and
recovery come with their first page (V1-2.5). ts-rs: 31 new type files, `types/index.ts` 126 entries.
@@ -3883,12 +3884,19 @@ recovery come with their first page (V1-2.5). ts-rs: 31 new type files, `types/i
1. The sanitiser keeps, removes and refuses exactly as before (R3 oracles O4/O5 green); its walk also lists, in
`active`, each removal that carried a script, an embedded document or image (`image`, `feImage`, `foreignObject`,
`iframe`, `object`, `embed`, media), animation, a link (`a`), an event handler (`on*`), a reference outside the
document (`href`, `url(…)`), `@import`, `javascript:`, `expression(`, `image-set(`, `behavior:`, or a backslash. A
`<style>` element is active when its text holds such a value, cleanable otherwise.
`iframe`, `object`, `embed`, media, and the HTML fetchers `img`, `input`, `source`, `frame`, `form`, `meta`, `link`,
`base`…), any element of the XHTML namespace, animation, a link (`a`), an event handler (`on*`), a fetching attribute
(`src`, `srcset`, `action`, `data`, `poster`, `http-equiv`…), a reference outside the document (`href`, `url(…)`),
`@import`, `javascript:`, `expression(`, `image-set(`, `behavior:`, or a backslash. A `<style>` element is active
when its text holds such a value, cleanable otherwise. A processing instruction other than the XML declaration
(`<?xml-stylesheet …?>`), which the tree never reads but the stored bytes would keep, refuses the file in the
cleaning (`svg_active_content`, named `?<target>`) and in the verdict (`svg_rejected`, `processing_instruction`);
the hostile file `comments-pi-cdata.svg` moved from clean to refused.
2. The cleaning reads a picked file with one difference from the stored-drawing reader: an oversized `title` or `desc`
(over 4 KiB) is a removal (the cleaned text drops it) where the stored reader refuses the file (`too_complex`).
3. `clean_svg` answers `cleaning_unstable` if a cleaned text did not read back with no removal; the property test proves
(over 4 KiB) is a removal (the cleaned text drops it) where the stored reader refuses the file (`too_complex`); its
subtree is still classified, so active content inside it refuses the file.
3. `clean_svg` answers `cleaning_unstable` if a cleaned text did not read back with no removal and serialise to
itself (what the admin confirms is what every reader draws); the property test proves
it never happens on the corpus and 3 000 generated drawings, and the check stays so no upload rests on the test.
4. The document measure is exact for texts written as JavaScript writes numbers (every core output); a page that sends
another spelling (`1.50`, `1E2`) is stored as written and may measure a few bytes differently.
@@ -3905,21 +3913,26 @@ recovery come with their first page (V1-2.5). ts-rs: 31 new type files, `types/i
and local to their group, an omitted marking digesting as `inherited`, coverage, a derived version deleting a zone
with its removal group and change list, removal digests bound to their key, an inherited element alone keeping its
group uncoverable, added / changed / status-changed / removed-plus-added, a reorder changing the digest only.
- `sheet_verdict` (13): a clean sheet and the equine draft pass (fingerprint `12d78872…`, 30 groups, 184 105 bytes); the
- `sheet_verdict` (14): a clean sheet and the equine draft pass (fingerprint `12d78872…`, 30 groups, 184 105 bytes); the
shape the SQL reads; each rule and drawing fault alone; caps at cap − 1 / cap / cap + 1 (annotations, labels in
astral characters, depth, nodes, drawings, document bytes); code order; determinism; base and removal groups; a
astral characters, depth, nodes, document bytes; views, drawings, drawing bytes and total bytes through
`caps_report`); code order; determinism; base and removal groups; a
document at every cap (64 views, 1 024 annotations, 8 192 nodes, depth 8) verified.
- `sheet_preview` (8): the equine draft previews with the bundle's index tables and canvases and its fingerprint; hash
- `sheet_preview` (9): the equine draft previews with the bundle's index tables and canvases and its fingerprint; hash
mismatch refused in every mode; fingerprint, missing drawing and caps refused for published and deprecated, reported
for drafts; an invalid draft draws with its issues; five replacements, one drawing read; read-only published; no
report operation on a preview.
report operation on a preview; at most 16 drawings of at most 2 MiB.
- `sheet_edit` (11): each marking rule of §6.6, the refusals, `dependents`, the facade, and 400 random commands on the
small sheet and on the equine draft (strict re-read, keys kept unless removed, nothing turned `inherited`).
- `svg_clean` (8): the 42 hostile files, each on the §9.2 line it belongs to; active names; a plain `<style>` cleaned and
small sheet and on the equine draft, view crops and drawings, references, zones included (strict re-read, every
key kept by every command but `remove`, which takes only the key and its descendants, the marking rule of each
command, `mark_reviewed` on its zone only, nothing turned `inherited`).
- `svg_clean` (10): the 42 hostile files, each on the §9.2 line it belongs to; the security audit's 13 probes
(stylesheet PIs, active content under a long title, HTML fetchers, XHTML elements) refused; a stored PI refused by the
verdict; active names; a plain `<style>` cleaned and
named, four hostile ones refused; the product drawing clean with its sha256; the four committed exports; the owner's
folder (empty so far); the fixpoint on the corpus and on 3 000 generated drawings (123 clean, 2 697 cleanable, 180
reference cycles refused).
- Mutation run (10 mutants, each against its suite): caps off by one, digest without its key, no active class, hash
- Mutation run (10 mutants, each against its suite; `.claude/audits/2026-10-29-v1-2-2-mutations.py`): caps off by one, digest without its key, no active class, hash
unchecked, an update keeping `reviewed`, fingerprint unchecked, `inherited` counted as read, redrawn views ignored,
numeric scale ignored, removal groups never made: 10 killed (the `inherited` one survived the first run; the test
that kills it was added).
@@ -3931,13 +3944,19 @@ recovery come with their first page (V1-2.5). ts-rs: 31 new type files, `types/i
| Measure | Value |
|---|---|
| shipped module | 1 771 003 B raw, 582 722 B gzip -9 (script), 592 136 B by Node's gzip in `size.test.ts`; budget 600 000 (D-R13); 531 715 B before V1-2.2 |
| shipped module | 1 777 104 B raw, 584 686 B gzip -9 (script), 593 582 B by Node's gzip in `size.test.ts`; budget 600 000 (D-R13); 531 715 B before V1-2.2 (RUST.md §11.22) |
| verdict at every cap, native | 107 ms release, 493 ms debug (document 1 165 850 bytes) |
| `clean_svg`, shipped module | 45 hostile inputs and floods, slowest 0.4 ms |
Security audit (fresh, on 741c25c): PASS, two MEDIUM and two LOW fixed in the same step. Fresh verifier (same
commit): ECARTS(6), all closed in the same step (the long-title MEDIUM, the property test's insert and
`mark_reviewed` checks, the cap − 1 fixtures of views, drawings and bytes, a floor false positive, record wordings) (processing instructions
kept in uploaded bytes; active content classed cleanable under a long title or as HTML fetchers; review groups built
in quadratic time, now one indexed pass; the runtime fixpoint check now compares the serialisation too).
### 12.6 Residual risks and points for V1-2.3
- The module's margin under its budget is about 8 KB by the test's measure: the V1-2.5 and V1-2.6 pages must not grow the
- The module's margin under its budget is about 6 KB by the test's measure: the V1-2.5 and V1-2.6 pages must not grow the
core's browser surface without measuring.
- cairo writes colours as `rgb(…)`: the allowlist removes any function from presentation attributes, so its cleaned
exports lose their colours (named, visible in the preview). Allowing `rgb()` / `rgba()` with numeric arguments would be a
@@ -1201,6 +1201,15 @@ supplied; they are not invented.
referential gaps are left to the validation panel. A `dependents(key)`
query feeds the delete confirmations. TypeScript holds no schema of its own
and no Zod copy; it reads the ts-rs types.
- As built in V1-2.2 (implementation reading, for the owner's confirmation): the
wire ops are `insert`, `update`, `remove`, `move` (the reorder), `set_status`
and `mark_reviewed`; besides what breaks strict parsing they refuse what would
leave an element unaddressable or outside the editor's offer
(`duplicate_key`, `unknown_key`, `id_changed`, `invalid_position`, `too_deep`
beyond 8 finding levels); removing a view or a category leaves the
annotations that name it in place, dangling for the validation panel, which
`dependents` lists before the confirmation (§6.6 « with descendants » read
as the finding tree's children).
- Ids are generated by the page (`<prefix>-<10 lowercase base32
characters>`, alphabet `a-z2-7`, inside the stable-id rule), passed to the
core, never derived from labels, never editable, never reused.
@@ -1305,6 +1314,16 @@ The page reads the file with the core SVG reader before anything is stored.
| Any other removal (editor metadata and namespaces, `data-*` attributes, `<style>` elements, `class` or `style` on the root, ids outside the grammar, unsupported elements such as `symbol`, oversized `title` or `desc`) | cleaning offered: « Nettoyer et utiliser cette version », after the composed preview of the cleaned drawing and one confirmation; a removed `<style>` element is named, since the `class` attributes it styled then render unstyled |
| No removal | used as is |
- Stricter than the table, as built in V1-2.2 (for the owner's confirmation):
an `<a>` link is refused even when it points inside the document, and so is
a value holding a backslash (a CSS escape can spell `url(` or `javascript:`),
`expression(`, `image-set(` or `behavior:`, an HTML element (XHTML namespace,
or a fetcher such as `img`, `meta`, `form`) and an HTML fetching attribute
(`src`, `srcset`, `action`, `http-equiv`…).
- A processing instruction other than the XML declaration (`<?xml-stylesheet …?>`)
is refused as active content: the reader's tree never sees it, but the stored
bytes would keep it; the verdict refuses a stored drawing that carries one
(V1-2.2, security audit).
- An oversized `title` or `desc` is a removal for the cleaning only: the reader
of stored drawings refuses such a file whole (`too_complex`), so it reaches
Storage only cleaned (V1-2.2).