fix(anatomy): V1-2.2 read url() references in their strict spelling only

Security review BLOCK(1): url(#%61) passed the dangling check and the
per-view scoping and resolved in browsers. One strict reading now, other
spellings are active content; glued names are other functions; the
composer refuses an unscoped reference; owner export procedure.
This commit is contained in:
bchanot committed 2026-10-29 16:49:15 +01:00
1 parent 5281337412
commit a678faaa23
13 files changed
+553 -70

No files matched your search

+30 -10
View File
@@ -3865,7 +3865,8 @@ marking is written `inherited`): `general` is the document without `views`, `ann
**Verdict codes,** first one recorded as the round's `failure_code`: `verification.integrity.document`, `.base`,
`verification.validation.rules`, `.no_geometry`, `.caps`, `verification.integrity.drawing_missing`, `.size_mismatch`,
`.object_conflict` (bytes not hashing to the row, which is the object key), `.svg_rejected`, `.svg_removal`,
`.fingerprint`. Drawing results: `ok`, `missing`, `size_mismatch`, `hash_mismatch`, `svg_rejected`, `svg_removal`.
`.svg_not_canonical` (§12.7), `.fingerprint`. Drawing results: `ok`, `missing`, `size_mismatch`, `hash_mismatch`,
`svg_rejected`, `svg_removal`, `svg_not_canonical`.
### 12.2 Facade
@@ -3915,27 +3916,28 @@ trapping test stub (`apps/app/tests/helpers/core.ts`) lists the two new glue mem
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` (14): a clean sheet and the equine draft pass (fingerprint `12d78872…`, 30 groups, 184 105 bytes); the
- `sheet_verdict` (15, the stored form included, §12.7): 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, 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` (9): the equine draft previews with the bundle's index tables and canvases and its fingerprint; hash
- `sheet_preview` (11, the stored form included): 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; 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
- `sheet_edit` (12, removals refused while named, §12.7): each marking rule of §6.6, the refusals, `dependents`, the facade, and 400 random commands on the
small sheet and on the equine draft, view crops and drawings, references, zones included (strict re-read;
on the marked elements, annotations, categories and nodes: every key kept by every command but `remove`, which
takes only its key and descendants, the rule of insert, update, move, set_status and `mark_reviewed`; nothing
turned `inherited`). The keys of views, references, regions and annotation categories and the redraw rule are held
by the case tests, not by the property test.
- `svg_clean` (10): the 42 hostile files, each on the §9.2 line it belongs to; the security audit's 13 probes
- `svg_clean` (14 since §12.7): 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).
named, four hostile ones refused; the product drawing clean with its sha256; the committed exports (four, three
Inkscape ones since §12.7); the owner's folder (empty so far); the fixpoint on the corpus and on 3 000 generated
drawings (138 clean, 2 434 cleanable, 428 refused: 256 dangling references, 172 reference cycles; before §12.7:
123 / 2 697 / 180 cycles).
- 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
@@ -3948,7 +3950,7 @@ trapping test stub (`apps/app/tests/helpers/core.ts`) lists the two new glue mem
| Measure | Value |
|---|---|
| shipped module | 1 785 447 B raw, 587 470 B gzip -9 (script), 596 671 B by Node's gzip in `size.test.ts` (final, ca31b78); budget 600 000 (D-R13); 531 715 B before V1-2.2 (RUST.md §11.22) |
| shipped module | 1 511 410 B raw, 558 651 B gzip -9 (script), 568 416 B by Node's gzip in `size.test.ts` (final, after §12.7: the debug `name` section dropped); budget 600 000 (D-R13); 596 671 B at ca31b78, 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 |
@@ -3967,7 +3969,7 @@ with a PI shown `rejected` by the preview as the verdict refuses it.
### 12.6 Residual risks and points for V1-2.3
- The module's margin under its budget is about 3.3 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 31.6 KB by the test's measure since §12.7 (3.3 KB before): the V1-2.5 and V1-2.6 pages must not grow the
core's browser surface without measuring.
- cairo colours: closed at the checkpoint (§12.7), strict numeric `rgb()` / `rgba()` kept.
- Editor exports: Inkscape 1.4.3 covered at the checkpoint (§12.7); Illustrator, Figma and Affinity pending from the
@@ -4017,6 +4019,24 @@ Inkscape: not installed and inkscape.org unreachable that day (504, then a timeo
`apt-get download`, unpacked with `dpkg-deb -x` into the session scratch folder and run from there (no install, no sudo).
`crates/core/tests/fixtures/svg/exports/generate-inkscape.sh` writes the three exports from `inkscape-source.svg`.
Security review of this round (fresh, 2026-10-29, BLOCK(1) HIGH, fixed in the same step): the sanitiser kept `url(#`
followed by any character, while the dangling check and the scoping read an id only from an id character, so
`url(#%61)` (and, in Chromium, `url('#<TAB>a')`) passed both and resolved in browsers, which percent-decode the fragment;
the expansion budget was walked around the same way (pre-existing since R3). Now `sanitize::local_url_target` is the one
reading of a `url(`: CSS whitespace, an optional quote, `#`, an id in the reference grammar, the same quote, CSS
whitespace, `)`; any other spelling is active content and refuses the file. A `url(` or `rgb(` glued to a longer name
(`xurl(`, `érgb(`, a non-ASCII letter included) is another function; a colour must end its value or list item. The
composer checks, fail-closed, that every reference of a canvas carries its view's scope (`unscoped_reference`). Tests
written apart from the reader: 14 refused spellings, 5 removed glued names, a 25 000-reference flood in `%61`, and a
browser model (percent-decoding, tab and newline stripping) over composed canvases (`svg_scope`). The R3 sanitiser
oracles needed no new declared change.
Residual (MEDIUM, security review): the scope is the view id, unique in one document only. A page that inlines canvases
of two documents at once (two versions side by side, two sheets) would share `fv.main.` and resolve in the first one in
tree order; such a page (V1-2.7 or later; the side-by-side diff is level 2, contract §8.3) must add a per-document
prefix before it ships. The detail modal of the report editor draws another view of the same document, so its scope
differs.
Size (V1-2.2 final, by Node's gzip in `size.test.ts`): see §12.5. Contributors measured on a build keeping the name
section: code 1 283 513 B in 1 808 functions (gzip ≈ 462 KB) and data 219 920 B (gzip ≈ 90 KB); by crate, raw code:
`faunosteo_core` 46 % (`domain::sheet` 204 KB, of which `schema` 68 KB and `edit` 42 KB; `pdf::write` 91 KB;
+16 -3
View File
@@ -1220,6 +1220,9 @@ supplied; they are not invented.
deletion is offered in level 1. An `insert` or `update` that names an
element absent from the document stays allowed (left to the validation
panel), as does a document saved with gaps: the verdict refuses them.
Structural rules that name nothing (`view.unreachable` after the last link
to a view goes, `view.main.count` after the main view goes) are left to
the validation panel too.
- 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.
@@ -1363,7 +1366,12 @@ The page reads the file with the core SVG reader before anything is stored.
so a new form is a new sha256, a new row and a new object.
- Local references (owner decision 2026-10-29): every `href="#id"`,
`xlink:href="#id"` and `url(#id)` must name an id the drawing itself
defines; a reference to an absent id is a hard rejection
defines, and a `url(` is a local reference only in its strict spelling
(CSS whitespace, an optional quote, `#`, an id in the reference grammar,
the same quote, CSS whitespace, `)`): `url(#%61)`, a tab, a space or an
unbalanced quote inside, an empty or non-ASCII id are active content and
refuse the file, since a browser normalises them (security review of the
checkpoint); a reference to an absent id is a hard rejection
(`dangling_reference`) for the reader of stored drawings, the cleaning
(after active content is classified, so a hostile file is still named as
such), the verdict and the preview. Valid internal references keep working.
@@ -1371,7 +1379,8 @@ The page reads the file with the core SVG reader before anything is stored.
keep the strict colour functions cairo writes, lowercase `rgb(` with three
and `rgba(` with four components, all bare numbers up to 255 or all
percentages up to 100, an alpha up to 1 or 100 %, commas, CSS whitespace,
nothing glued before the name. Every other function (`url(` outside the
nothing glued before the name (a non-ASCII letter included) and nothing
after the `)` but the end, a space, `;`, `,` or `!`. Every other function (`url(` outside the
document, `expression(`, `var(`, `hsl(`, an escaped name, an uppercase
name…) is removed or refused as before; scripts and active CSS stay
refused.
@@ -1477,7 +1486,11 @@ A drawing never blocks authoring: only the round waits for its verdict.
transformation runs at composition only: stored bytes, their sha256, the
published versions, the archive snapshot and the PDF views (each rasterised
as a document of its own) keep the drawing's ids. Composition is
deterministic and applied once per call. A drawing outside the stored form
deterministic and applied once per call; the composer refuses a canvas
that would keep a reference outside its scope (`unscoped_reference`).
The scope is unique within one document only: a page that inlines
canvases of two documents at once (two versions or two sheets side by
side) adds a per-document prefix first. A drawing outside the stored form
(§9.2) shows `rejected` with `not_canonical` and draws nothing, as the
verdict refuses it.
- `LoadedSheet` (the report editor's sheet) keeps its mandatory migration map;