Skip to content

fix(ci): enforce the cargo-audit CVSS>=7 gate + remediate quick-xml DoS - #333

Merged
CameronBrooks11 merged 3 commits into
mainfrom
fix/cargo-audit-cvss-gate
Jul 15, 2026
Merged

CameronBrooks11 merged 3 commits into
mainfrom
fix/cargo-audit-cvss-gate

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Why

The Cargo Audit job has been red on main (weekly schedule) and on every open PR, and — more importantly — it never actually enforced its stated "block on CVSS ≥ 7.0" policy. Investigating the current failure surfaced a real, live High-severity finding that the gate was silently letting through. This is a "do it right" fix: it remediates the vulnerability and fixes the gate so this class of miss can't recur.

Three distinct defects

  1. Live vulnerability (High). quick-xml 0.39.4 (transitive via plist → tauri-utils → tauri) carries two CVSS 7.5 DoS advisories, RUSTSEC-2026-0194 / RUSTSEC-2026-0195, patched in quick-xml ≥ 0.41.0.

  2. The gate never ran. cargo audit --json > cargo-audit.json runs under bash -e. cargo-audit exits non-zero on any advisory (including informational unmaintained/unsound warnings — there are 17 in the tree), so the step aborted before the gate step, which also skipped the report upload.

  3. The gate was a no-op even when reached. It did float(cvss), but the RustSec cvss field is a CVSS v3.x vector string ("CVSS:3.1/AV:N/…"), not a number. float() raised and was swallowed by except ValueError: continue, so every vulnerability was skipped — a CVSS 9.8 would have passed.

What changed

Remediation (fix(deps)):

  • Bump plist 1.9.0 → 1.10.0, which pulls quick-xml 0.39.4 → 0.41.0. Allowed under tauri's plist = "^1"; no tauri bump required. cargo audit reports 0 vulnerabilities after.

Gate fix (fix(ci)):

  • Move gating into scripts/ci/cargo_audit_gate.py, which computes the CVSS v3.0/3.1 base score from the vector and fails on any score ≥ 7.0.
  • Fail closed: a missing/malformed report (real tool/network error) raises in the gate instead of passing.
  • Nothing silent: reports blocking, below-threshold, and unscored vulns (unscored get a ::warning::), plus informational-warning counts.
  • if: always() on all three audit uploads (cargo/pip/npm) so reports survive a gate failure.
  • tests/ci/test_cargo_audit_gate.py locks in the CVSS math and the block-on-high / fail-closed paths, so the float(cvss) regression can't come back unnoticed.

Verification

  • Gate blocks on the live report (flags both quick-xml CVSS 7.5) and passes after the plist bump — verified end-to-end via the committed script against real cargo audit --json output.
  • ruff check, ruff format --check, pre-commit hooks: clean. Full suite: 263 passed (19 new).
  • CVSS scorer unit-tested against known vectors (7.5, 9.8, 10.0 scope-changed, 1.8, CVSS 3.0).

Notes / follow-ups (not in this PR)

  • The three audit jobs use different block policies by design — cargo: CVSS ≥ 7.0; pip-audit: any advisory; npm: high+. Worth a deliberate decision on whether to align them.
  • Unscored vulnerabilities are reported but do not block (preserves the prior CVSS-threshold intent). Tightening this to fail-closed is a one-line policy change if wanted.

Remediates two High-severity (CVSS 7.5) denial-of-service advisories in
quick-xml 0.39.4, reached transitively via plist -> tauri-utils -> tauri:

  - RUSTSEC-2026-0195: unbounded namespace-declaration allocation in
    NsReader enables memory exhaustion
  - RUSTSEC-2026-0194: quadratic run time when checking a start tag for
    duplicate attribute names

Both are patched in quick-xml >=0.41.0. plist 1.10.0 depends on
quick-xml 0.41 and satisfies tauri's `plist = "^1"` constraint, so no
tauri bump is required. cargo audit reports zero vulnerabilities after
the update.
The Cargo Audit job never enforced its intended "block on CVSS >= 7.0"
policy — it failed for the wrong reasons and, even when reached, gated on
nothing. Two independent defects:

1. `cargo audit --json > cargo-audit.json` ran under `bash -e`. cargo
   audit exits non-zero whenever it finds *any* advisory (including
   informational unmaintained/unsound warnings), so the step aborted
   before the gate — which also skipped the report upload. The job
   failed on sub-threshold findings and never evaluated severity.

2. The gate did `float(cvss)`, but the RustSec `cvss` field is a CVSS
   v3.x *vector string* (e.g. "CVSS:3.1/AV:N/..."), not a number. The
   float() raised and was swallowed by `except ValueError: continue`,
   so every vulnerability was silently skipped. Even had the step been
   reached, it would have passed a CVSS 9.8.

Fix:
- Capture the report tolerantly (`|| true`) and move all gating into
  scripts/ci/cargo_audit_gate.py, which computes the CVSS v3.0/3.1 base
  score from the vector and fails (exit 1) on any score >= 7.0.
- Fail closed: a missing/malformed report (real tool/network error)
  raises in the gate rather than passing.
- Report every finding: blocking, below-threshold, unscored (with a
  ::warning:: annotation), and informational-warning counts — nothing is
  silently dropped.
- Upload all three audit reports with `if: always()` so they survive a
  gate failure (pip-audit and npm audit had the same report-loss).
- Add tests/ci/test_cargo_audit_gate.py covering the CVSS math, the
  block-on-high and fail-closed paths, so this cannot silently regress.

Verified against the live report: blocks on the two quick-xml CVSS 7.5
advisories, passes after the plist bump remediates them.
Adversarial review caught the gate computing the CVSS v3.0 changed-scope
impact sub-score (`(iss - 0.02) ** 15`) while claiming v3.1. v3.1 uses
`(iss * 0.9731 - 0.02) ** 13`; the v3.0 form under-scores changed-scope
vectors by up to ~0.1, which flips a real vulnerability from 7.0 to 6.9
at the gate boundary — a silent miss, exactly what this gate exists to
prevent. (Scope-unchanged is unaffected: v3.0 == v3.1 there.)

- Switch to the v3.1 changed-scope impact and correct the docstring.
- Pin the difference with tests: two changed-scope vectors expecting the
  v3.1 scores (9.7, 7.0) that a v3.0 regression would fail (9.6, 6.9),
  plus a gate-level test asserting the 7.0 boundary vuln now blocks.
- Harden the report-shape check to fail closed gracefully when
  `vulnerabilities.list` is absent (was an uncaught KeyError).
@CameronBrooks11

Copy link
Copy Markdown
Member Author

Adversarial subagent review found one real correctness defect: the gate computed the CVSS v3.0 changed-scope impact sub-score while claiming v3.1, under-scoring changed-scope vectors by up to ~0.1 — enough to flip a real vuln from 7.0 to 6.9 at the gate boundary (a silent miss). Fixed in d8b17ae: switched to the v3.1 changed-scope formula, pinned it with discriminating tests (9.7/7.0 vs the v3.0 9.6/6.9), added a gate-level boundary block test, and hardened the report-shape check to fail closed gracefully. All other checks (fail-closed paths, workflow wiring, dependency bump, common-case CVSS math) verified sound. 22 tests pass.

Note: this PR's Python Audit job remains red — that's the separate pillow/setuptools advisory set, remediated in a follow-up PR, not in scope here.

@CameronBrooks11
CameronBrooks11 merged commit 9276ac0 into main Jul 15, 2026
20 of 21 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/cargo-audit-cvss-gate branch July 15, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant