ADR-0004: Explainable Offline ML (ACI@3.0 & Pre-KEV) Seam
- Status: Accepted
- Date: 2026-11-30
- Deciders: Quashawn Ashley
- Tags: ml|aci|scoring|enrichment|security|schema|runtime-policy
Context
VulnParse-Pin v2.0.x provides deterministic Attack Capability Inference (ACI@2.0) using rule-based token/chain matching and deterministic Track A (cve_threat) scoring using current CISA KEV, FIRST EPSS v5, CVSS, and verified exploit signals. Two enterprise pain points remained:
- Unseen vendor/scanner phrasing & false-positive negation: Novel vulnerability descriptions outside exact
tn_triage.jsontokens can missACIcapability labels or struggle when advisory text mixes exploit keywords with negation clauses. - Reactive KEV lag: Using point-in-time EPSS alone does not distinguish stable moderate-EPSS CVEs from rapidly accelerating threats likely to enter CISA KEV next.
Any ML solution for security triage in regulated, MSSP, or air-gapped enclaves must preserve deterministic reproducibility, hard policy precedence, offline verifiability (zero runtime outbound downloads or remote LLM dependencies), and audit-defensible explainability.
Decision
Introduce an Explainable Offline ML Seam (src/vulnparse_pin/ml/) integrated across ACI@3.0 (aci_pass.py), ScoringV3Pass (scoringPass.py), app/enrichment.py, DiffEngine (core/diff_engine.py), RunManifest (utils/runmanifest.py), and vpp ml (cli/commands.py):
- Signed Distilled Core Models (
src/vulnparse_pin/ml/registry.py,distilled.py,resources/models/):- Package compact (
< 2 MB, enforcedMAX_MODEL_ARTIFACT_BYTES = 2 * 1024 * 1024) pure-Python JSON artifacts verified fail-closed before load:aci_v3_core.json(115,696bytes, 9 calibrated linear models coveringremote_execution,command_execution,auth_bypass,sql_injection,privilege_escalation,initial_access,deserialization,ssrf, andnegated_false_positive).pre_kev_v1_core.json(3,353bytes, calibrated EPSS-velocity + exploit-momentum Pre-KEV breakout predictor).
- Every model ships a detached
.sig.jsonverified via SHA-256 digest and optional HMAC-SHA256 usingVP_MODEL_HMAC_KEY(MODEL_HMAC_ENV), symlink/world-writable checks (_read_verified_regular_bytes), and strict NaN/Infinity JSON rejection. - Optional
[ml]extra (onnxruntime>=1.20.0, MIT) is supported viaprovider: auto | core | onnxalongsideMAX_ONNX_ARTIFACT_BYTES = 64 MiB; core pure-Python execution remains 100% functional without native ONNX binaries. - Optional
[ml-train]extra (scikit-learn>=1.5.0, BSD-3-Clause) supports external training/export, with a clean pure-Python regularized logistic + Platt scaler fallback inbenchmarks/ml/train_models.pyandcalibration.py.
- Package compact (
- Three-Mode Governance (
ml.mode: off | shadow | active):shadow(default): Preserves 100% numeric and priority-tier parity with deterministicv2.0.xScoringV3Pass(applied_uplift = 0.0), while computing and recording calibratedml_acicapability probabilities and top-K signed token/feature attributions inscores.score_trace_json(score_trace["ml_aci"]),aci_signals.ml_*columns, andenrichment_snapshots.pre_kev_*telemetry.active: Applies bounded uplift (capped byml.max_aci_uplift, default1.25) ONLY whennegated_false_positive < 0.50and max offensive capability probability>= 0.60. Opt-in viaconfig.yaml(ml.mode: active) or CLI--ml-mode active(vpp scan,vpp demo).off: Bypasses ML artifact loading and overlay evaluation completely; enforces emptymodel_ids/model_hashesinRunManifest.ml_governance.
- Strict Precedence of Hard Policy Invariants:
- Deterministic hard controls strictly override ML uplift: CISA KEV
P1,BOD 26-04SSVC decision tree rules,triage.static_sast_p1_cap(static_sastfindings cannot be elevated toP1by ML alone), anddecisions.yamlvalid deferrals/mitigations/acceptances.
- Deterministic hard controls strictly override ML uplift: CISA KEV
- EPSS Velocity & Pre-KEV Breakout Detector (
pre_kev.py,enricher.py):EPSSFeedCacheretains a 90-dayepss_historytable in HMAC-signedepss_cache.sqlite3.compute_epss_velocity()calculates 7-day/30-day deltas (epss_delta_7d,epss_delta_30d) and trailing log-odds OLS slope (epss_slope), persisted onenrichment_snapshotsand evaluated byPreKEVModelagainstml.pre_kev_threshold(default0.65).vpp diff --fail-on pre-kevtriggers exit code2on newly flagged Pre-KEV breakout findings;vpp uiexposes hotkeybandvpp mcpfilterspre_kev=true.
- Cryptographic Model Governance in
RunManifest(utils/runmanifest.py):- Seals
ml_governance(ml_mode,provider,model_ids,model_hashes) insideverification.manifest_digest, rejecting tampered or mismatchedml_governanceblocks onvpp verify.
- Seals
Alternatives Considered
- Bundle PyTorch /
sentence-transformersor call external LLMs:- Pros: Richer generative explanations.
- Cons: Violates
< 2 MBweight budget, offline air-gapped operation, latency SLAs (< 50msper 10k distinct signatures), and deterministic reproducibility.
- Enable
ml.mode: activeas the default:- Pros: Immediate score uplift for uncalibrated text phrasing.
- Cons: Changes numeric
v2.0.xbaseline scores unexpectedly on existing pipelines before teams observe calibration inshadowmode. Defaulting toshadowguarantees backwards-compatible scores while unlocking full attributions and Pre-KEV telemetry immediately.
Consequences
Positive:
- Explainable top-K token/feature contributions (
score_trace["ml_aci"]["ml_attributions"]) and Platt-calibrated probabilities fit inside< 120 KBof core JSON artifacts with zero runtime network dependencies. - Existing
v2.0.xCI thresholds remain untouched by default (ml.mode: shadow). - Every scan seals exact
model_idsandsha256:model_hashesintoRunManifestfor audit defense.
Negative:
- Adds
mlpolicy schema fields (config.schema.json,runManifest.schema.json) and additive DuckDB columns (aci_signals.ml_*,enrichment_snapshots.epss_*/pre_kev_*). - Organizations tuning custom models must sign updated JSON artifacts and distribute shared
VP_MODEL_HMAC_KEYsecrets to offline enclaves.
Compatibility & Licensing Impact
- Classification:
additive - Affected contracts:
config.schema.json(mlsection),runManifest.schema.json(ml_governance), DuckDBaci_signals&enrichment_snapshots, CLI--ml-modeonvpp scan/vpp demo,--fail-on pre-kevonvpp diff, and newvpp mlsubcommand. - Clean-room Apache-2.0 dependency compliance verified:
yes(pure Python core; optional[ml]onnxruntimeis MIT; optional[ml-train]scikit-learnis BSD-3-Clause). - Migration guidance: Legacy
v1andv2.0.xconfig.yamlfiles automatically projectml = MLPolicyV2()(mode="shadow"). Existingv2.0.x.vpp.dbfiles auto-migrate viaensure_v21_schema()on write or fall back cleanly on read-only queries.
Test and Validation Plan
- Contract & schema tests: Config validation/projection (
ConfigValidator,MLPolicyV2),RunManifestml_governanceround-trip (_verify_ml_governance_block),vpp ml status|eval|calibrate|trainCLI contracts, andml.mode: off | shadow | activenumeric parity & uplift tests (tests/test_ml_aci_v3.py,tests/test_epss_velocity_pre_kev.py,tests/test_vpp_ml_cli.py). - Security / adversarial tests: Tampered model JSON /
.sig.jsonrejection, missing/mismatchedVP_MODEL_HMAC_KEYfail-closedModelIntegrityError, symlink and world-writable artifact rejection, NaN/Inf payload rejection,> 2 MiBcore size bomb rejection, and precedence guardrails verifyingstatic_sast_p1_cap& KEVP1cannot be inverted by ML (tests/test_ml_aci_v3.py). - Runtime & latency verification: Deterministic calibration scorecard (
benchmarks/ml/scorecard.json) and< 50 msbatch inference across10,000distinct signatures inDistilledLinearModel.score_signatures_batch.
Rollout and Rollback
- Rollout: Ships in
ml.mode: shadowby default inv2.1.0; security teams inspectml_attributionsandPre-KEVwatchlist (bhotkey /vpp mcp) and opt into--ml-mode activeper engagement or policy. - Rollback: Set
ml.mode: offinconfig.yamlor--ml-mode offon CLI to bypass all ML loading and inference immediately.