Files
faunosteo/.claude/audits/2026-10-23-rust-r5-review-security-6.md
T

10 KiB
Raw Blame History

Security gate R5.4, round 6 (fresh, blind)

Branch feature/rust-r5-pipeline-core, HEAD aeb5050. Scope: git diff c6e0d85..HEAD -- crates/core packages/anatomy/tests docs/development/RUST.md (25 files). Mode: audit (this file is the only write). The brief carried a list of earlier findings; per the auditor contract it was not used as a checklist. The scan below is complete on its own and covers those areas anyway.

SECURITY — VERDICT: PASS
TOOL: semgrep 1.168.0 — p/security-audit, p/secrets, p/owasp-top-ten
SCOPE: 25 files
BLOCKING:
  (none)
REPORTED (non-blocking):
  - [MEDIUM] resource/changelog-table-amplification — crates/core/src/curation/draft/changelog.rs:100 (via crates/core/src/curation/markdown.rs:133)
  - [LOW] resource/per-view-drawing-amplification — crates/core/src/curation/draft/pipeline.rs:204
  - [LOW] resource/guard-underscore-pairing-quadratic-in-isolation — crates/core/src/curation/report_guard.rs:216
  - [LOW] markdown/invisible-hangul-fillers-admitted — crates/core/src/curation/report_guard.rs:159
  - [LOW] markdown/unpadded-wiki-link-in-table-cell (context, by design) — crates/core/src/curation/report_guard.rs:58
  - [LOW] anti-gaming/clippy-allow-in-new-test-file (context, convention) — crates/core/tests/curation_markdown.rs:6
  - [LOW] anti-gaming/clippy-allow-in-new-test-file (context, convention) — crates/core/tests/curation_review.rs:6
PROOF: semgrep 162 rules on 25 files → 0 findings; checklist 13 checks → 7 findings

What was run

  • semgrep 1.168.0, the three pinned packs, --metrics=off, on the 25 existing files of the diff: 162 rules, 25 files scanned, 0 results, 0 errors.
  • Checklist greps on the added lines: secrets, SQL concatenation, unsafe render, logging, suppressions, tracked .env / credential files (only .env.example is tracked). Nothing found. No endpoint in scope (authz check N/A).
  • Guardrails scanner (--domain api,supabase): 0 FAIL, 1 WARN, 1 MANUAL. The WARN (SB-POLICY-NOT-OWNER, supabase/migrations/20261008110000_anatomical_sheets.sql:1177) is outside the diff, not counted.
  • cargo test -p faunosteo-core --features curation: every suite green. cargo clippy --all-targets -D warnings (curation): clean. No std::fs, std::env, clock or process use in the new core modules (only the binary, which already carried its documented allow).
  • import-equine --check: legacy 6 files 0 differences; draft 12 files 0 differences, one declared: line for review/app-main.svg.
  • Differential fuzz of report_guard::format_report against Prettier 3.8.3 (the TypeScript formatter, same options as packages/anatomy/src/format.ts), through a scratch binary on the core library. 10,201 generated reports (seeded random strings over the admitted alphabet plus Markdown tokens: URL starts, entities, **, [[, ](, <a, {%, [^1], :warning:, line-start markers), placed in the list-item fields (with the pipeline's own assert_single_line / assert_authored pre-filters) and in CHANGELOG table cells (with the cell() escape). 2,226 admitted, 7,975 refused. 0 admitted report differs from Prettier's output. AST census of every admitted report (Prettier's own Markdown parser): heading, list, item, table, row and code-span counts always equal the template's; no link other than a bare URL autolink literal, no image, HTML, emphasis, footnote, definition, break, liquid node. One wikiLink node, in a table cell (see LOW 5).
  • Table width parity: 28 unusual letters (combining marks with the Alphabetic property, Indic vowel signs, CJK, fullwidth, halfwidth, Hangul jamo and fillers, non-BMP letters) in a table cell: 26 admitted and identical to Prettier, 2 refused. No silent alignment difference.
  • Guard timing on 12 pathological 0.4 to 1 MB lines (debug build): 32 to 224 ms each, linear.
  • --out / --check file safety, 18 probes in the scratchpad: fresh folder (18 files, diff -r identical but the declared app-main.svg); non-empty folder, symbolic link (plain, trailing /, trailing /.), dangling link (target not created), path inside the seed, inside the seed through a linked parent, link to draft/, .., empty path, existing file, missing parent, /, extra arguments: every one refused, nothing written; non-absolute INIT_CWD falls back to the current folder. The seed and the git tree are unchanged.
  • Resource probe on the real equine pipeline (scratch binary, release build, ulimit -v).

Findings

MEDIUM 1: the CHANGELOG grows as rows × the widest cell of each column

changelog.rs:100 level_section builds one table per level, and format_report aligns it (markdown.rs:133 align, :163 padded): every row is padded to the widest cell of its column. Titles and rationales are authored and uncut (only Avant / Après are cut to 120 units). One change with a long rationale plus another change producing many records makes every row as wide as that rationale. Measured on the equine pipeline, all level A:

added to changes.json records CHANGELOG max RSS
+25 KB (200 subtree sets) 5,226 7.8 MB 45 MB
+45 KB (same, one 20 KB rationale) 5,226 98 MB 233 MB
+105 KB (same, one 80 KB rationale) 5,226 381 MB 788 MB
+155 KB (600 sets, one 80 KB rationale) 14,026 1.09 GB 2.2 GB

A rationale cloned into many records (the R5.3 shape) aborted at 4.4 GB under a 6 GB ulimit from +175 KB. Within the 16 MiB read cap the demand reaches terabytes: certain OOM of the tool, and --out would try to write a file of that size (into a fresh folder, never overwriting). Prettier aligns tables the same way, so the TypeScript had the same output. This is not the declared R5.3 residual (records cost ops × items × value size): here a single wide cell multiplies every row, with the records themselves staying small. No integrity or confidentiality impact; a local developer tool fed by an authored file that goes through review. Hint: compute the aligned size (rows × the sum of column widths) before building the strings and refuse past a stated cap with a loud PipelineError, or cap authored title / rationale length. Declare the bound in RUST.md next to the 200,000-value one.

LOW 2: two drawings per view, no view count bound

pipeline.rs:204 review_drawings writes an overlay and an application drawing per view, each a clone of the whole cleaned drawing (overlay.rs:350, app_review.rs:27), about 137 KB each, all held in memory before any write or comparison. A detail view needs about 25 document values (view, view box, trigger annotation), so the 200,000-value bound allows about 7,700 views: around 2.1 GB of output. Estimated, not measured. Same output as the TypeScript. Hint: the same output-size cap as MEDIUM 1 covers it.

LOW 3: underscore_pairs_later is O(parts × length) on its own

report_guard.rs:216: for each plain part holding _ it rescans every later code span. 40,000 a_b \cN`parts (509 KB) took 213 s (debug). The generator never writes such a line: at most two authored parts per line (title + rationale, question) and the separators between code spans hold no_`; the realistic worst case, one underscore part followed by 100,000 code spans (1 MB), takes 224 ms. So the "linear guard" holds for the generator's line shapes only. Hint: one backward pass that records whether a later code span can close.

LOW 4: invisible Hangul fillers pass the allowlist

report_guard.rs:159 admits char::is_alphanumeric, which includes U+3164, U+115F, U+1160 and U+FFA0 (Hangul fillers, category Lo, rendered blank). An authored title or rationale can carry invisible runs in REVIEW-REPORT.md. No structure is forged and Prettier keeps them (identical output). Hint: refuse Default_Ignorable_Code_Point letters with the other refused classes.

LOW 5 (context, by design): unpadded [[x]] admitted in a table cell

Only padded wiki links are refused in cells (report_guard.rs:58); list items refuse [[ and ]] whole (review_report.rs:364). Prettier parses [[x]] in a CHANGELOG cell as a wikiLink and prints it back byte for byte, so the output matches the TypeScript. Recorded so the per-cell rule stays a conscious choice.

LOW 6 (context): clippy allow attributes in the two new test files

tests/curation_markdown.rs:6 and tests/curation_review.rs:6 add #![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]. They are not security-scanner suppressions (no nosemgrep, nosec, eslint-disable): they are the convention clippy.toml documents ("Tests and the worker binary allow these lints locally where they own I/O"), present in the same form in all 34 existing integration test files. Not blocking.

Areas checked and found sound

  • Report structure: no authored text reaches a line start (control characters refused in list-item fields, \n → space and \r refused in cells); code spans come from the generator only (authored backticks refused, content limited to [A-Za-z0-9_:/. -], field segments to [A-Za-z0-9_-], change ids CHG-\d{3,}, reference ids declared and stable, ids written by an op checked at the op); ](, ][, ![, < before a letter / / / ! / ?, character references, {%, %} refused; * only as **word**; _ only intraword plus the code-span closer rule; backslash only before " or |; table cell count checked.
  • SVG: elements and attribute names are fixed or come from the frozen drawing read by the core's reader (refused if anything is removed); values escaped (& < > ", \t \n \r as references in attributes); XML-invalid code points and CR refused (drawing.rs:41); file names built from stable view ids.
  • --check: the tree fallback only for review/app-*, only with the declared rule, and only when the committed file rebuilds from its tree byte for byte, the rule changes it and the result equals the produced bytes; the committed file goes through the core reader's prescan first.
  • --out: .. refused, final symbolic link refused (trailing slash handled), parent canonicalised, seed refused by path and by (device, inode) of every seed folder, existing destination identity-checked and must be empty, folders create_dir, files create_new, components all Normal. The swap window between check and use stays as declared (§11.13).