Enrichment Deep Dive
This document explains VulnParse-Pin v2.1.0 (Apache-2.0) threat-intelligence enrichment sources, unified CVSS provenance, EPSS velocity and Pre-KEV hydration, DuckDB snapshot hydration (enrichment_snapshots), and fail-closed security controls.
Purpose
Enrichment augments normalized findings with external threat intelligence and authoritative severity/exploitability provenance without overwriting raw scanner observations. In v2.1.0, matched CVE and Package URL (package_purl) intelligence—alongside trailing EPSS velocity metrics and optional offline PreKEVModel breakout predictions—is hydrated per run_id into DuckDB’s enrichment_snapshots table and runs.intel_metadata_json.
Enrichment Sources (6 Source Families)
| Source | Cache / Storage | Lookup Keys | Key Signals Hydrated |
|---|---|---|---|
| CISA KEV | kev_cache.json + kev_cache.sqlite3 |
CVE |
in_kev, kev_date_added, kev_due_date, kev_ransomware, kev_required_action, catalog_version |
| EPSS v5 | epss_cache.csv + epss_cache.sqlite3 (epss_scores, epss_history) |
CVE |
epss_score, epss_percentile, epss_model_version (#model_version), epss_date, epss_delta_7d, epss_delta_30d, epss_slope |
| NVD | nvd/feeds/*.json.gz + nvd_cache.sqlite3 |
CVE |
CVSS v4.0/v3.1/v3.0/v2.0 vector & score, cvss_provenance (NVD vs CNA), source_identifier |
| GHSA | ghsa_cache.sqlite3 (API or offline JSON/dir) |
CVE, GHSA, package_purl |
Advisory IDs, CVSS v4/v3, references (ghsa_package_index PURL matching) |
| OSV | osv_cache.sqlite3 (offline JSON/dir/.zip) |
CVE, GHSA, package_purl |
Advisory IDs, CVSS v4/v3/v2, references (osv_package_index PURL matching) |
| Exploit-DB | files_exploit.csv (FeedCacheManager) + text heuristic |
CVE, finding text |
verified_exploit, exploit_refs_json, separated from heuristic_exploit_mention |
CISA KEV (KEVFeedCache)
- Uses
FeedCacheManagerfor remote/offline retrieval (known_exploited_vulnerabilities.json) and indexes records inkev_cache.sqlite3(signed.sig.json). - Hydrates full KEV fields into
enrichment_snapshots:in_kev,kev_date_added,kev_due_date,kev_ransomware, andkev_required_action.
EPSS v5 (EPSSFeedCache), Trajectory History, & Pre-KEV Hydration
- Parses FIRST EPSS v5 comment headers (
#model_version:...,score_date:...) and extracts both raw probability (epss_score) and FIRST percentile (epss_percentile). - Maintains a trailing
epss_history(cve_id, score_date, epss_score, epss_percentile)table insideepss_cache.sqlite3(src/vulnparse_pin/utils/enricher.py) so historical EPSS observations persist across feed refreshes. - Stores
epss_model_versionandepss_dateinepss_cache.sqlite3,enrichment_snapshots, andruns.intel_metadata_jsonsoDiffEnginecan track model changes and threshold crossings (0.04/0.10, percentile0.90/0.95). populate_enrichment_snapshots()queriesEPSSFeedCache.query_history()(falling back to prior DuckDBenrichment_snapshotswhen fewer than 2 distinct dates exist) and runscompute_epss_velocity()(src/vulnparse_pin/ml/pre_kev.py) to computeepss_delta_7d,epss_delta_30d, andepss_slope(trailing log-odds OLS slope).- When
ml_pol.mode != "off"(default"shadow") andepss_scoreis present,PreKEVModel(pre_kev_v1_core) scores breakout likelihood and writespre_kev_score,pre_kev_flag, andpre_kev_reasons_jsonintoenrichment_snapshots(consumable byvpp diff --fail-on pre-kevandRemediation@1.0).
NVD (NVDFeedCache)
- Indexes NVD CVE JSON 2.0 feeds into
nvd_cache.sqlite3, extracting the highest-tier CVSS metric (cvssMetricV40->cvssMetricV31->cvssMetricV30->cvssMetricV2). - Uses
source_identifierto distinguish authoritative NVD scoring (nvd@nist.gov->cvss_provenance = "NVD") from CNA-supplied scoring ("CNA").
GHSA (GHSAEnrichmentSource)
- Activated explicitly via
--ghsa [PATH|online](config does not auto-enable). - Online mode queries
https://api.github.com/advisories/...bounded by--ghsa-budget(default25). Token resolution checksenrichment.ghsa_token_env(defaultVP_GHSA_TK, validated against^[A-Za-z_][A-Za-z0-9_]{0,127}$), falls back toGITHUB_TOKEN, rejects\r/\nheader-injection characters, and validates GitHub token prefixes (ghp_,gho_,ghu_,ghs_,ghr_,github_pat_). - Offline mode loads advisory JSON files/directories into
ghsa_cache.sqlite3(ghsa_cve_indexandghsa_package_index), supporting PURL ecosystem/package matching viaparse_purl().
OSV (OSVEnrichmentSource)
- Optional offline advisory source activated via
--osv <PATH>(JSON file, ecosystem directory, or.zipbundle) orvpp intel sync --feed osv --osv <PATH>. - Indexes advisories in
osv_cache.sqlite3(osv_advisories,osv_cve_index,osv_ghsa_index,osv_package_index) with<= 900-parameter chunked queries and strict zip path-traversal / zip-bomb validation (OSVSecurityError).
Exploit-DB & Negation-Aware Heuristics
- Verified exploit references:
files_exploit.csv(from Exploit-DB or--exploit-db <CSV>) populatesverified_exploit = Trueandexploit_refs_json. - Negation-aware heuristic separation:
is_heuristic_exploit_mention()(src/vulnparse_pin/utils/exploit_enrichment_service.py) scrubs explicit negations via_NEGATED_EXPLOIT_RE(e.g.,"not exploitable","no known exploit","unexploitable","without exploit","unlikely to be exploited","cannot be exploited") before matching_POSITIVE_EXPLOIT_RE. - Heuristic mentions populate
heuristic_exploit_mention(0.0default scoring points) separately fromverified_exploit, preventing false inflation and preventing KEV + Exploit-DB double-counting (verified_exploit_with_kev_points = 0.5).
Unified CVSS Provenance Precedence
resolve_cvss_with_provenance() (src/vulnparse_pin/utils/enricher.py) enforces strict provenance ordering across CVSS v4.0, v3.1, v3.0, and v2.0 vectors:
NVD > CNA > GHSA > OSV > Scanner-Supplied > Missing
- Whenever a valid vector exists without a score (or with a vector-derivable score), base scores are computed via the clean-room Apache-2.0 calculator in
src/vulnparse_pin/utils/cvss_utils.py(no LGPLcvssdependency). - In
populate_enrichment_snapshots(), CVE snapshots intentionally filter outScanner-SuppliedCVSS so finding-specific scanner vectors remain bound to the finding whileScoring@3.0(resolve_effective_cvss_fields) blends snapshot provenance with scanner fallback without"Missing"shadowing"Scanner-Supplied".
DuckDB Hydration (populate_enrichment_snapshots)
In vpp scan, populate_enrichment_snapshots() (src/vulnparse_pin/app/enrichment.py):
- Queries
.vpp.dbfor only the distinct CVEs (finding_cves/findings.primary_cve) andpackage_purls present in the currentrun_id. - Hydrates KEV, EPSS v5 (plus
epss_delta_7d,epss_delta_30d,epss_slope, andPreKEVModelfields whenml.mode != "off"), NVD, GHSA, OSV, and Exploit-DB records and computes source-attributed confidence (enrichment.confidence,model_version: v2). - Bulk-inserts snapshot rows via DuckDB
appenderinto_stg_enrich_snap->INSERT OR REPLACE INTO enrichment_snapshotsand updatesruns.intel_metadata_json.
Integrity, Network & Inspection Controls
- HMAC anti-downgrade: When
VP_FEED_CACHE_HMAC_KEY(FeedCacheManager) orVP_SQLITE_HMAC_KEY(all 5 SQLite caches) is set, plainsha256sidecars or unsigned pre-existing DBs fail verification closed with zero auto-resign; tampered SQLite caches are quarantined to.tampered.<UTCSTAMP>. - HTTPS streaming: Remote fetches use
_open_https_stream/stream_https_get_bytes(allow_redirects=Falsewith per-hop HTTPS validation,MAX_REMOTE_FEED_BYTES = 200 MiB,MAX_DECOMPRESSED_FEED_BYTES = 2 GiB,MAX_NVD_META_BYTES = 1 MiB). - Read-only inspection:
vpp intel statusverifies cache integrity and row counts read-only (?mode=ro) without mutating files or resigning caches.