← Back to Pull requests

feat(cvss): FIRST's formulas from Red Hat's cvss library; 4.0 scored, stated scores checked (D12) #514

Closed
unknown closed this pull request without merging on Nov 18, 2026 20:20 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 18:57 UTC
Author

@smith-xyz Here's the migration to Red Hat's cvss library you suggested (multi-feed CVSS plan, decision D12). One part needs your review as a core maintainer: it widens the models third-party allowlist for cvss, confined to one module.

What it does

  • Core's hand-rolled CVSS 3.0/3.1 calculator is replaced by Red Hat Product Security's cvss 3.6 (LGPLv3+, used unmodified as a library, pinned exactly in pyproject.toml). The library also scores CVSS 4.0.

  • A source that states a vector without a score gets the computed one. OSV's GHSA records state 4.0 that way, and core had no 4.0 formula, so these showed no score.

  • A stated 4.0 score must now agree with its vector, as a 3.x one already must (score_of).

  • Core's stricter checks stay in front of the library: canonical case, 4.0 metric order, no repeated metric. The library itself accepts out-of-order 3.1 and 4.0 vectors.

  • Unchanged: a 4.0 score is shown beside the chosen 3.x score and never ranked (D2). cvss_base_score keeps its 3.x-only float contract for AdvisoryRecord.cvss_score.
  • Layering (needs review)

  • tests/v1/test_layering.py: cvss joins the models allowlist.

  • tests/v1/test_architecture.py: test_only_the_cvss_model_imports_the_cvss_library confines the import to models/cvss.py, the same one-module pattern as tree_sitter, jwt and traust_ledger.

  • cvss_base_score moves from models/dependencies.py into models/cvss.py, so models/cvss.py no longer imports dependencies (the direction reverses).
  • The reasoning: FIRST's formula is a pure computation on one value, which is what models owns. A provider is for things outside the process.

    Evidence before replacing core's formula

    | Check | Result |
    |---|---|
    | Every CVSS 3.0/3.1 base vector (2,592 each), core's formula against the library | 5,184 / 5,184 identical |
    | Two weeks of NVD records (2026-11-01 to 11-15, 2,000 CVEs), stated 4.0 score against the library | 730 / 730 match |
    | Same records, stated 3.x scores | 1,726 / 1,726 match |

    The new 4.0 test vectors include two published CNA statements with threat and supplemental metrics (9.3 with E:P, 2.3 with E:U). They were scored outside core and outside this library, so the tests don't assert the library against itself.

    Verification

  • make test: 14,942 passed. Lint and the ratchet are clean.

  • Live smoke test from a built wheel. OSV's GHSA-223j-4rm8-mrmf (GitHub-reviewed, npm next) states only a 4.0 vector. On current development it scores None. With this change it scores 1.7, which is GitHub's own published 4.0 score for that advisory (gh api /advisories/GHSA-223j-4rm8-mrmf). GHSA-jfh8-c2jp-5v3q (3.1) stays at 10.0.
  • Licensing: the LGPL was accepted for this library (owner, 2026-11-17). traust's docs/external-dependencies.md licence row lands with the traust pin bump.

    🤖 Generated with Claude Code

    Diff: 366 lines (+274 / -92) across 4 files Reviewer: chubirka Review duration: 83m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 366 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.353
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #514"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%