# Security gate, final: Rust R5.7 (deletion of packages/anatomy and packages/domain) Date 2026-10-25. Branch `feature/rust-r5-pipeline-core`. Scope `756b7ef..27bf59c` (152 paths: 8 added, 32 modified, 2 renamed, 110 deleted; 2 055 insertions, 17 542 deletions, 7 commits `0da7d3a`..`27bf59c`). Fresh auditor; the previous report `2026-10-25-rust-r5-7-security.md` was read only for the status check the brief asked for. ``` SECURITY — VERDICT: PASS TOOL: semgrep 1.168.0 — p/security-audit, p/secrets, p/owasp-top-ten SCOPE: 42 files (the existing files of the diff; 110 deleted paths inspected through git) BLOCKING: (none) REPORTED (non-blocking): - [MEDIUM] pnpm-audit (pre-existing, no version touched by the diff) — pnpm-lock.yaml — 57 advisories on unchanged versions: 2 critical (tinypool 1.1.1 via vitest, dev), 33 high (pnpm 10.13.1 itself x17, brace-expansion, js-yaml, nanoid, postcss, source-map-js, happy-dom, zod 3.25.76), 21 moderate, 1 low - [LOW] census-regex-gap — apps/app/tests/unit/r5.census.test.ts:300 — `#[ignore]` placed before `#[test]`, or `#[cfg_attr(…, ignore)]`, still passes the ledger-target check (no instance in the tree) - [LOW] new-suppression (clippy allow, not a security-tool suppression) — crates/core/tests/curation_leaves.rs:6 — identical header in all 41 files under crates/core/tests - [LOW] SB-POLICY-NOT-OWNER (guardrails WARN, pre-existing, file not in the diff) — supabase/migrations/20261008110000_anatomical_sheets.sql:1177 PROOF: semgrep 158 rules (725 loaded, 3 packs) on 42 files → 0 findings, 0 errors, 0 skipped; checklist 8 checks → 0 findings; guardrails scan.py api,supabase → 0 FAIL, 1 WARN (outside diff), 1 MANUAL (not reported); anti-gaming 1 new clippy allow (LOW), 0 removed; cargo deny check advisories → ok; pnpm audit → 57 advisories, 0 introduced; ledger 407 rows / 566 cargo targets → 566 active #[test], 0 #[ignore] ``` ## Semgrep `semgrep scan --config p/security-audit --config p/secrets --config p/owasp-top-ten --metrics=off --quiet --json <42 paths>`: 0 results, 0 errors, 0 skipped paths, stderr empty. The verbose rerun reports 725 rules loaded, 158 applicable to the languages present, 42 files. ## Checklist (8 checks, 0 findings) | Check | Result | |---|---| | Hardcoded secret, token, key, auth URL in added lines | None. Hits are variable names in prose (`SUPABASE_SERVICE_ROLE_KEY` in CLAUDE.md and the previous audit), no value. URLs in added lines are all LEDGER.tsv case descriptions (`https://x.test/…`, `http://localhost:5173`, `https://faunosteo.com`, the partner credit, `https://zenquality.fr`): test and product data, no credential. No IP, no `/home/`, no `/Users/`. | | SQL by concatenation | No new SQL. `seed.rs` keeps `sql_text` quote doubling and the `$equine_doc$` dollar tag with the refusal at line 94 (`DOCUMENT_DOLLAR_TAG`). The diff on that file is a 3-line doc comment. | | Unsanitized render (innerHTML, eval, raw) | None. | | Sensitive endpoint without authz | No endpoint, policy or RPC in the diff. | | Stack trace / internal path to the user | None. | | Secret or PII to a log | None. | | Tracked `.env` or credential file | Only `.env.example` is tracked (`git ls-files`); `.gitignore` and `.dockerignore` exclude `.env`, `.env.*`, the gateway htpasswd and the Mailpit password. No binary in the diff (`git diff --numstat` shows no `-` row); the largest added file is `LEDGER.tsv` (173 KB, UTF-8 text). | | Guardrails scanner (api,supabase, 1219 files) | 0 FAIL. 1 WARN `SB-POLICY-NOT-OWNER` on `species_select_active` (pre-existing, file not in the diff). 1 MANUAL `SB-RLS-LIVE`, not reported here. | ## Anti-gaming One new suppression-like marker in the added lines: `#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]` at `crates/core/tests/curation_leaves.rs:6`. It is a clippy allow, not a semgrep, bandit or ESLint-security suppression, and every one of the 41 files under `crates/core/tests/` carries the same single header (`disallowed_methods` forbids I/O and clock in the library; integration tests read fixtures). LOW, not blocking. No `nosemgrep`, `nosec`, `eslint-disable`, `@ts-ignore`, `@ts-expect-error`, `.skip` or `#[ignore]` added; no suppression removed. ## Supply chain ### Lockfile `pnpm-lock.yaml`: 1 insertion, 69 deletions. - Removed: importers `packages/anatomy` and `packages/domain`; the `packages:` and `snapshots:` entries of `@xmldom/xmldom@0.9.12`; the `deprecated:` metadata line of `eslint@9.39.4` (registry metadata, same version). - Added: the single line `optional: true` on the `tsx@4.23.15` snapshot. `tsx` appears in no manifest (`git grep '"tsx"' -- '*/package.json'` → none); it stays resolved only as vite's optional peer, per the owner decision C6 (`27bf59c`). - No new package, no version change, no `overrides`, `patchedDependencies`, `onlyBuiltDependencies` change (`pnpm-workspace.yaml` untouched). ### cargo deny `. scripts/rust-env.sh` (read first: appends `~/.cargo/bin` to PATH when no cargo is found, installs nothing) then `cargo deny check advisories` (cargo-deny 0.20.2, `deny.toml` `yanked = "deny"`, `ignore = []`): `advisories ok`. No build, no `target/` access. ### pnpm audit (read-only) `pnpm audit --json` with the local pnpm 10.13.1: 57 advisories, `{critical: 2, high: 33, moderate: 21, low: 1}`. Every advisory sits on a package version the lockfile diff did not change, so none is introduced by this scope; they are reported, not gated, and belong to a separate `chore/*`. Breakdown by reachable surface: | Package (version) | Advisories | Surface | |---|---|---| | pnpm 10.13.1 (root devDependency, `packageManager`, Dockerfile `corepack prepare pnpm@10.13.1`) | 17 high + 8 moderate, patched in 10.26 … 10.34.5 (lifecycle-script bypass, lockfile integrity bypass, env-var command injection, manifest identity spoof running attacker lifecycle, secrets exfiltration through `pnpm-workspace.yaml` proxy placeholders, several path traversals) | developer machine and the Docker builder stage; the Docker build runs `pnpm install --frozen-lockfile` on a repository-controlled lockfile. The CLAUDE.md pin rationale ("10.x line stays pinned") is compatible with 10.34.5. | | tinypool 1.1.1 (vitest) | 2 critical (prototype-pollution RCE in worker options) | dev only (test runner) | | brace-expansion 1.1.14 / 5.0.6 (eslint, typescript-eslint) | 8 high + 2 moderate (DoS) | dev only | | js-yaml 4.3.0 (eslint) | 2 high (CPU DoS) | dev only | | vitest 3.2.7, @vitest/mocker | 3 moderate | dev only | | happy-dom 20.10.6 | 1 high | dev only | | vite 7.3.6 | 1 high, 4 moderate, 1 low (launch-editor, `server.fs.allow`) | dev server and build | | postcss 8.5.14, nanoid 3.3.12, source-map-js 1.2.1 (vite, tailwind) | 2 high + 1 moderate, 2 high, 1 high | build time | | zod 3.25.76 (apps/app, core-wasm, supabase runtime dependency) | 1 high "memory exhaustion on oversized constrained collections", patched in zod 4.6.6 only | runtime, browser-side form validation of the user's own input: self-DoS of one's own tab, no server impact | ## No lost validation `crates/core/tests/curation/LEDGER.tsv`: 407 rows (144 anatomy, 263 domain), dispositions `ported` 256, `replaced` 149, `deleted` 2, `kept` 0. Targets: 566 `cargo …::` parts (154 distinct functions), 8 `vitest …` parts, 25 `import-equine --check`. Independent resolution (script in the auditor's scratchpad, not the census): for each cargo target every `fn (` under the named binary's files was located and its whole contiguous attribute block inspected, in any attribute order. Result: 566/566 resolve to a function carrying `#[test]` with no `ignore` token in the block; 0 unresolved, 0 non-test, 0 ignored. The 8 vitest files exist. The one `#[ignore]` in the crate (`pdf_serialize.rs:811`, release-only timing) predates the diff (`babe7b7`, 2026-10-18, present at `756b7ef`) and is not a ledger target. | Control named in the brief | Ledger rows | Rust test (active `#[test]`) | Implementation | |---|---|---|---| | Sheet integrity rules | 69 (40 ported, 29 replaced) | `sheet_rules::{view_main_count, view_id_duplicate, view_parent_missing, view_parent_cycle_*, view_unreachable, view_asset_missing_*, annotation_id_duplicate_across_views, …}`, `sheet_rules::the_curated_draft_validates_with_no_issue`, `sheet_rules::the_horse_slice_has_no_issue` | `crates/core/src/domain/sheet` | | Changeset refusals | 174 (120 ported, 53 replaced, 1 deleted: purity, see below) | `curation_draft::the_synthetic_cases_match_the_typescript_or_are_refused_alike` + oracle `oracles/r5/curation-synthetic.json`, plus the per-case ported tests in `curation_draft.rs` | `crates/core/src/curation/draft/{apply,ops,targets,fields}.rs` | | Reserved ids | 4 (3 ported, 1 replaced) | `curation_draft::a_changeset_reusing_the_reserved_asset_change_id_is_refused`, `report_rules::report_v3_schema_defaults_and_refusals` | `curation/draft`, `domain/report` | | Seed dollar-quote guard | 1 ported | `curation_draft::a_document_holding_the_dollar_quote_tag_is_refused_by_the_seed` (`curation_draft.rs:1075`, asserts the error names `$equine_doc$`) | `curation/draft/seed.rs:13,94` | | SVG sanitising | 24 (10 ported, 12 replaced, 2 deleted: not sanitiser cases, matched on wording) | `svg_sanitiser::{every_hostile_case_gives_the_typescript_verdict_or_a_declared_one, every_generated_case_…, the_product_svgs_come_out_untouched, a_rejection_names_a_closed_reason}` iterating the 42 `fixtures/svg/hostile/*.svg` against `oracles/r3/sanitiser.json` (452 KB); `sheet_shape::refuses_what_zod_refuses` for the `javascript:` reference | `crates/core/src/anatomy/svg/{prescan,sanitize,refs}.rs` | The two `deleted` rows carry no control: "applyChangeset never mutates its inputs" is a JavaScript aliasing check with no Rust meaning (`apply_changeset(baseline: &Value, …)`, `apply.rs:210`); "horse slice JSON fixture equals the TypeScript lean input" was the TS generator of `fixtures/horse-slice.json`, now the source file, read by `sheet_index`, `sheet_rules` and `sheet_shape`. Declared functional loss, confirmed as not a security loss: the xmldom re-cleaning of a legacy SVG (`packages/anatomy/src/curation/assets.ts`, FILES.tsv row `replaced`) is not ported; the pipeline reads the committed `draft/assets/horse.svg` and the application loads every drawing through `anatomy::svg::read_svg` regardless of origin. The four `crates/core/src` changes in the diff (`anatomy/mod.rs`, `curation/mod.rs`, `domain/mod.rs`, `curation/draft/seed.rs`) are doc comments only (11 insertions, 2 deletions, no code line). ## Dockerfile and build `Dockerfile`: the two `COPY packages/{domain,anatomy}/package.json` lines are removed; the builder stage copies exactly the four manifests the lockfile has importers for (`.`, `apps/app`, `packages/supabase`, `packages/core-wasm`) before `pnpm install --frozen-lockfile`, then `COPY . .`. The folders `packages/anatomy`, `packages/domain` and `packages/pdf` still exist on disk with a git-ignored `node_modules/` only (0 tracked files each) and `.dockerignore` excludes `**/node_modules/`, so nothing of them enters the image. `crates/worker/Dockerfile`, `docker/rust-builder.Dockerfile`, `scripts/`, `.gitea/workflows`, tsconfig, vite and vitest configs: no reference to the deleted paths (`git grep` over tracked non-doc files returns only the ESLint ban list, the two census tests and Rust `//!` provenance comments). `package.json`: `import:equine:legacy` removed; `packages/supabase/package.json`: `assets:upload:legacy` removed with its script `scripts/upload-sheet-assets.ts` (the Rust `upload-sheet-assets` binary remains the operator path). `apps/app/eslint.config.js` adds `@faunosteo/anatomy` and `@xmldom/xmldom` to the `no-restricted-imports` ban. ## Census tests cannot pass vacuously `r5.census.test.ts` asserts positives before negatives: the manifest list must contain the four remaining packages; the lockfile importer set must equal the manifest set exactly; `packages.length > 100` and a `zod@` key; more than 100 scanned sources containing the `@faunosteo/core-wasm` specifier; the Dockerfile `COPY` list must contain the two package manifests and each must exist; FILES.tsv > 80 rows with every counterpart present (112 rows: 55 ported, 48 replaced, 9 deleted, all package tooling or test helpers); LEDGER.tsv exactly 407 rows (144 + 263); every oracle path present; every cargo target resolved to a `#[test]` fn; the two moved fixtures pinned by SHA-256 (verified: `e96b0882…b729c` and `ba79698c…fde7` match `sha256sum`). `r4.census.test.ts` extends the bans and checks the importer split finds `['.', 'apps/app', 'packages/core-wasm']` before asserting absences. Residual gap (LOW): the ledger regex at `r5.census.test.ts:300-302` anchors on `#[test]` and then refuses attributes starting with `ignore`. Probed with Node against the exact regex: | Input | Census | |---|---| | `#[test]` / `fn foo(` | accepted | | `#[test]` / `#[ignore]` / `fn foo(` | refused (correct) | | `#[test]` / `#[ignore = "r"]` / `fn foo(` | refused (correct) | | `#[ignore]` / `#[test]` / `fn foo(` | accepted (bypass: rustc accepts both orders, `cargo test` skips it) | | `#[test]` / `#[cfg_attr(debug_assertions, ignore)]` / `fn foo(` | accepted (bypass) | | `fn foo(` alone, or `#[test] fn bar` then `fn foo` | refused (correct) | No ledger target is in either shape today (independent order-agnostic check above). Hint: scan the whole attribute block above `fn (` and refuse any `ignore` token in it, or assert `cargo test -- --list` output in `check-all.sh`. ## Status of the previous audit's two LOW findings | Previous finding | Status at 27bf59c | |---|---| | LOW clippy allow header, `curation_leaves.rs:6` | Unchanged. Same header as the 41 sibling test files; still LOW, still not a security-tool suppression. | | LOW census accepted any `fn (` | Fixed. `475a41d` requires `#[test]` with only attributes or doc lines between (`#\[test\]\s*(?:(?:#\[[^\]]*\]\|///[^\n]*)\s*)*fn`), `cd69f0e` adds `(?!ignore)` on those attributes. Residual gap above (attribute order, `cfg_attr`), LOW, no instance in the tree. | ## Not done (out of scope or forbidden) No command executed from the repository other than semgrep, the guardrails scanner, `pnpm audit` (read-only, registry query), `cargo deny check advisories` (no build) and read-only git, grep, sha256sum. No `cargo clean`, `pnpm install`, `pnpm format`, no test suite run (a `pnpm check:all` ran concurrently in the tree). The runtime behaviour of the ported Rust tests is attested by that gate, not by this audit; this audit attests they exist, carry `#[test]`, are not ignored, and map each ledger row.