Skip to main content
VulnParse-Pin emblem VulnParse-Pin emblem
VulnParse-Pin
Architecture ML Calibration and Benchmarks.md
View source on GitHub ↗

ML Calibration and Benchmarks

VulnParse-Pin v2.1.0 introduces Explainable Offline ML across two signed, sub-200 KB distilled core models under src/vulnparse_pin/resources/models/:

  • aci_v3_core (ACI@3.0): Calibrated 9-label linear text + structured-tag + numeric-primitive classifier predicting attack capabilities and false-positive negation cues, emitting signed top-K per-feature attributions inside score_trace["ml_aci"].
  • pre_kev_v1_core (Pre-KEV@1.0): Calibrated logistic + Platt-scaled breakout predictor consuming 7-day / 30-day EPSS deltas, trailing log-odds OLS velocity slope (epss_slope), CVSS normalization, and exploit-momentum signals.

For governance rules and cryptographic invariants (off / shadow / active, VP_MODEL_HMAC_KEY, RunManifest ml_governance), see ADR-0004: Explainable Offline ML Seam.


Measured Scorecard (benchmarks/ml/scorecard.json)

Evaluated reproducibly offline via benchmarks/ml/train_models.py using stratified deterministic train / calibration / holdout evaluation splits and Platt probability scaling (src/vulnparse_pin/ml/calibration.py):

Model Artifact Inventory

Model ID Version Artifact Path Size (Bytes) SHA-256 Digest
aci_v3_core 3.0.0 src/vulnparse_pin/resources/models/aci_v3_core.json 115,696 sha256:fa5073bd390b1b7e2f5b20a483ff8c02ef3a37cb4af8f1e9bf15e022f4f6cd2e
pre_kev_v1_core 1.0.0 src/vulnparse_pin/resources/models/pre_kev_v1_core.json 3,353 sha256:ed6befe9bb65155728b6933c46776fadf219bd76fc61da9e0068c6ee2e1cc40c

Both artifacts stay well under the 2 MiB (2,097,152 bytes) fail-closed core model cap (MAX_MODEL_ARTIFACT_BYTES) and ship paired with .sig.json verification manifests.

Aggregate Evaluation Metrics

Model Train Calibration Eval Holdout ROC-AUC PR-AUC Brier Score ECE (10-bin)
aci_v3_core (Macro) 544 136 255 1.0 1.0 0.002554 0.021553
pre_kev_v1_core (pre_kev) 480 120 250 1.0 1.0 0.001087 0.020575

NOTE
These reference metrics are measured on the open, reproducible synthetic/corpus holdout split in benchmarks/ml/train_models.py (training_backend: pure_python, 100 positive / 150 negative Pre-KEV holdout samples). Because real-world scanner phrasing and historical EPSS distributions vary across organizations, treat the bundled scorecard as a reproducible calibration baseline and re-evaluate against your own labeled corpus using vpp ml eval / vpp ml calibrate.

aci_v3_core Per-Label Breakdown (eval_samples = 255)

Capability Label Positives Negatives ROC-AUC PR-AUC Brier Score ECE
auth_bypass 33 222 1.0 1.0 0.002201 0.020918
command_execution 33 222 1.0 1.0 0.002624 0.021614
deserialization 15 240 1.0 1.0 0.004031 0.021389
initial_access 93 162 1.0 1.0 0.002385 0.026233
negated_false_positive 67 188 1.0 1.0 0.002421 0.023269
privilege_escalation 16 239 1.0 1.0 0.001774 0.016173
remote_execution 65 190 1.0 1.0 0.004539 0.032265
sql_injection 17 238 1.0 1.0 0.002254 0.018893
ssrf 15 240 1.0 1.0 0.000754 0.013222

Runtime Architecture & Precedence Guarantees

  1. Signature-Level Caching & Vectorized Batching (src/vulnparse_pin/ml/distilled.py):
    • DistilledLinearModel.score_signatures_batch() deduplicates unique scanner/advisory signatures and pre-indexes n-gram bigrams so 10,000 distinct signatures evaluate in < 50 ms without external numerical libraries.
  2. Explainable Top-K Attributions (src/vulnparse_pin/ml/aci_model.py):
    • Returns per-feature signed linear contributions (top_k_attributions, default 5) inside score_trace["ml_aci"]["ml_attributions"] alongside ml_capabilities, ml_confidence, applied_uplift, and negated_guarded.
  3. Hard Guardrails (src/vulnparse_pin/core/passes/Scoring/scoringPass.py):
    • shadow mode (default): applied_uplift = 0.0 (zero change to v2.0.x numeric scores or tiers) while capturing full ML attributions and Pre-KEV momentum.
    • active mode: Applies bounded uplift up to ml.max_aci_uplift (1.25 default) only when negated_false_positive < 0.50 and max offensive capability probability >= 0.60.
    • static_sast_p1_cap, CISA KEV P1, and BOD 26-04 SSVC rules strictly take precedence over ML adjustments.

Enterprise Calibration & Training Workflow (vpp ml)

Inspect bundled models, active runtime mode (off / shadow / active), and signature health:

vpp ml status --json

Evaluate a bundled or custom model against your organization’s labeled JSON/JSONL corpus:

vpp ml eval --model aci --corpus holdout_aci.jsonl --json

Recalibrate Platt scaling (fit_platt_scaler / calibrate_ml_model) on local historical labels and emit a signed model artifact:

vpp ml calibrate --model pre_kev --corpus pre_kev_cal.jsonl --output custom_pre_kev.json --json

Train a new signed pre_kev_breakout or aci_capabilities model offline:

vpp ml train --task pre_kev_breakout --corpus pre_kev_train.jsonl --output custom_pre_kev.json --json

Re-score or evaluate a scan in active ML mode after validating calibration metrics (ECE and Brier Score):

vpp demo --no-ui --ml-mode active --output-dir out_active

When distributing custom signed models to air-gapped enclaves, set VP_MODEL_HMAC_KEY during signing and runtime verification so tampered artifacts or unverified .sig.json sidecars fail closed with ModelIntegrityError.