Repository navigation
fix(ci): enforce the cargo-audit CVSS>=7 gate + remediate quick-xml DoS - #333
Conversation
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).
|
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 |
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
Live vulnerability (High).
quick-xml 0.39.4(transitive viaplist → tauri-utils → tauri) carries two CVSS 7.5 DoS advisories,RUSTSEC-2026-0194/RUSTSEC-2026-0195, patched inquick-xml ≥ 0.41.0.The gate never ran.
cargo audit --json > cargo-audit.jsonruns underbash -e. cargo-audit exits non-zero on any advisory (including informationalunmaintained/unsoundwarnings — there are 17 in the tree), so the step aborted before the gate step, which also skipped the report upload.The gate was a no-op even when reached. It did
float(cvss), but the RustSeccvssfield is a CVSS v3.x vector string ("CVSS:3.1/AV:N/…"), not a number.float()raised and was swallowed byexcept ValueError: continue, so every vulnerability was skipped — a CVSS 9.8 would have passed.What changed
Remediation (
fix(deps)):plist 1.9.0 → 1.10.0, which pullsquick-xml 0.39.4 → 0.41.0. Allowed under tauri'splist = "^1"; no tauri bump required.cargo auditreports 0 vulnerabilities after.Gate fix (
fix(ci)):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.::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.pylocks in the CVSS math and the block-on-high / fail-closed paths, so thefloat(cvss)regression can't come back unnoticed.Verification
cargo audit --jsonoutput.ruff check,ruff format --check, pre-commit hooks: clean. Full suite: 263 passed (19 new).Notes / follow-ups (not in this PR)