Skip to main content
VulnParse-Pin emblem VulnParse-Pin emblem
VulnParse-Pin
Architecture adr/ADR-0004-explainable-offline-ml.md
View source on GitHub ↗

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:

  1. Unseen vendor/scanner phrasing & false-positive negation: Novel vulnerability descriptions outside exact tn_triage.json tokens can miss ACI capability labels or struggle when advisory text mixes exploit keywords with negation clauses.
  2. 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):

  1. Signed Distilled Core Models (src/vulnparse_pin/ml/registry.py, distilled.py, resources/models/):
    • Package compact (< 2 MB, enforced MAX_MODEL_ARTIFACT_BYTES = 2 * 1024 * 1024) pure-Python JSON artifacts verified fail-closed before load:
      • aci_v3_core.json (115,696 bytes, 9 calibrated linear models covering remote_execution, command_execution, auth_bypass, sql_injection, privilege_escalation, initial_access, deserialization, ssrf, and negated_false_positive).
      • pre_kev_v1_core.json (3,353 bytes, calibrated EPSS-velocity + exploit-momentum Pre-KEV breakout predictor).
    • Every model ships a detached .sig.json verified via SHA-256 digest and optional HMAC-SHA256 using VP_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 via provider: auto | core | onnx alongside MAX_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 in benchmarks/ml/train_models.py and calibration.py.
  2. Three-Mode Governance (ml.mode: off | shadow | active):
    • shadow (default): Preserves 100% numeric and priority-tier parity with deterministic v2.0.x ScoringV3Pass (applied_uplift = 0.0), while computing and recording calibrated ml_aci capability probabilities and top-K signed token/feature attributions in scores.score_trace_json (score_trace["ml_aci"]), aci_signals.ml_* columns, and enrichment_snapshots.pre_kev_* telemetry.
    • active: Applies bounded uplift (capped by ml.max_aci_uplift, default 1.25) ONLY when negated_false_positive < 0.50 and max offensive capability probability >= 0.60. Opt-in via config.yaml (ml.mode: active) or CLI --ml-mode active (vpp scan, vpp demo).
    • off: Bypasses ML artifact loading and overlay evaluation completely; enforces empty model_ids / model_hashes in RunManifest.ml_governance.
  3. Strict Precedence of Hard Policy Invariants:
    • Deterministic hard controls strictly override ML uplift: CISA KEV P1, BOD 26-04 SSVC decision tree rules, triage.static_sast_p1_cap (static_sast findings cannot be elevated to P1 by ML alone), and decisions.yaml valid deferrals/mitigations/acceptances.
  4. EPSS Velocity & Pre-KEV Breakout Detector (pre_kev.py, enricher.py):
    • EPSSFeedCache retains a 90-day epss_history table in HMAC-signed epss_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 on enrichment_snapshots and evaluated by PreKEVModel against ml.pre_kev_threshold (default 0.65).
    • vpp diff --fail-on pre-kev triggers exit code 2 on newly flagged Pre-KEV breakout findings; vpp ui exposes hotkey b and vpp mcp filters pre_kev=true.
  5. Cryptographic Model Governance in RunManifest (utils/runmanifest.py):
    • Seals ml_governance (ml_mode, provider, model_ids, model_hashes) inside verification.manifest_digest, rejecting tampered or mismatched ml_governance blocks on vpp verify.

Alternatives Considered

  1. Bundle PyTorch / sentence-transformers or call external LLMs:
    • Pros: Richer generative explanations.
    • Cons: Violates < 2 MB weight budget, offline air-gapped operation, latency SLAs (< 50ms per 10k distinct signatures), and deterministic reproducibility.
  2. Enable ml.mode: active as the default:
    • Pros: Immediate score uplift for uncalibrated text phrasing.
    • Cons: Changes numeric v2.0.x baseline scores unexpectedly on existing pipelines before teams observe calibration in shadow mode. Defaulting to shadow guarantees backwards-compatible scores while unlocking full attributions and Pre-KEV telemetry immediately.

Consequences

Positive:

  1. Explainable top-K token/feature contributions (score_trace["ml_aci"]["ml_attributions"]) and Platt-calibrated probabilities fit inside < 120 KB of core JSON artifacts with zero runtime network dependencies.
  2. Existing v2.0.x CI thresholds remain untouched by default (ml.mode: shadow).
  3. Every scan seals exact model_ids and sha256: model_hashes into RunManifest for audit defense.

Negative:

  1. Adds ml policy schema fields (config.schema.json, runManifest.schema.json) and additive DuckDB columns (aci_signals.ml_*, enrichment_snapshots.epss_* / pre_kev_*).
  2. Organizations tuning custom models must sign updated JSON artifacts and distribute shared VP_MODEL_HMAC_KEY secrets to offline enclaves.

Compatibility & Licensing Impact

  • Classification: additive
  • Affected contracts: config.schema.json (ml section), runManifest.schema.json (ml_governance), DuckDB aci_signals & enrichment_snapshots, CLI --ml-mode on vpp scan/vpp demo, --fail-on pre-kev on vpp diff, and new vpp ml subcommand.
  • Clean-room Apache-2.0 dependency compliance verified: yes (pure Python core; optional [ml] onnxruntime is MIT; optional [ml-train] scikit-learn is BSD-3-Clause).
  • Migration guidance: Legacy v1 and v2.0.x config.yaml files automatically project ml = MLPolicyV2() (mode="shadow"). Existing v2.0.x .vpp.db files auto-migrate via ensure_v21_schema() on write or fall back cleanly on read-only queries.

Test and Validation Plan

  1. Contract & schema tests: Config validation/projection (ConfigValidator, MLPolicyV2), RunManifest ml_governance round-trip (_verify_ml_governance_block), vpp ml status|eval|calibrate|train CLI contracts, and ml.mode: off | shadow | active numeric parity & uplift tests (tests/test_ml_aci_v3.py, tests/test_epss_velocity_pre_kev.py, tests/test_vpp_ml_cli.py).
  2. Security / adversarial tests: Tampered model JSON / .sig.json rejection, missing/mismatched VP_MODEL_HMAC_KEY fail-closed ModelIntegrityError, symlink and world-writable artifact rejection, NaN/Inf payload rejection, > 2 MiB core size bomb rejection, and precedence guardrails verifying static_sast_p1_cap & KEV P1 cannot be inverted by ML (tests/test_ml_aci_v3.py).
  3. Runtime & latency verification: Deterministic calibration scorecard (benchmarks/ml/scorecard.json) and < 50 ms batch inference across 10,000 distinct signatures in DistilledLinearModel.score_signatures_batch.

Rollout and Rollback

  • Rollout: Ships in ml.mode: shadow by default in v2.1.0; security teams inspect ml_attributions and Pre-KEV watchlist (b hotkey / vpp mcp) and opt into --ml-mode active per engagement or policy.
  • Rollback: Set ml.mode: off in config.yaml or --ml-mode off on CLI to bypass all ML loading and inference immediately.

References