fix(cve): KEV from CISA's GitHub mirror, exploitation cached per source (#493)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 12m6s

On stage and prod www.cisa.gov answers 403 to the datacenter, so the KEV
catalog was never read. Since a CVE's row was cached only when KEV, EPSS
and Vulnrichment all answered, cve_exploitation stayed empty and every
scan asked EPSS and Vulnrichment again.

- KEV is read from CISA's mirror cisagov/kev-data on
  raw.githubusercontent.com (same feed, CC0), with www.cisa.gov as the
  fallback.
- KEV is applied from the cached catalog on every run and no longer
  stored per CVE. A cve_exploitation row keeps EPSS and SSVC, each with
  an *_answered flag, merged with $set so a later answer keeps the
  other's. A source that failed is asked again alone; a row expires a
  day after its first write. Rows from before have no flag and are asked
  again.
- Tests: KEV fallback after a 403, a blocked KEV that keeps EPSS and
  SSVC, a retry that asks only EPSS, the merge, old rows, and the Mongo
  write path (skipped without Mongo).
- Docs: tools reference (source and egress rows), test plan check 19.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-06 20:50:24 +02:00
1 parent 85aff4cd2c
commit ad1394af4f
3 files changed
+431 -143

No files matched your search

+3 -3
View File
@@ -196,7 +196,7 @@ Every CVE alert is enriched with what is known about its exploitation, after the
| Source | What it says | Licence | How it is read |
|---|---|---|---|
| [CISA Known Exploited Vulnerabilities (KEV)](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) | the CVE is exploited in the wild; the date CISA added it; known use in ransomware campaigns | CC0 1.0 | the whole catalog (one JSON file, about 2 MB), at most once a day |
| [CISA Known Exploited Vulnerabilities (KEV)](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) | the CVE is exploited in the wild; the date CISA added it; known use in ransomware campaigns | CC0 1.0 | the whole catalog (one JSON file, about 2 MB), at most once a day: from CISA's mirror on GitHub ([cisagov/kev-data](https://github.com/cisagov/kev-data)), else from `www.cisa.gov`, which refuses many datacenter addresses |
| [FIRST EPSS](https://www.first.org/epss) | the probability that the CVE is exploited in the next 30 days, and its percentile | free to use; FIRST asks for attribution | FIRST's API, up to 50 CVE ids per request |
| [CISA Vulnrichment](https://github.com/cisagov/vulnrichment) | the SSVC decision point *Exploitation* (`none`, `poc`, `active`) | CC0 1.0 | the CVE's record in the GitHub repository (`<year>/<n>xxx/CVE-….json`); a CVE CISA has not rated is a 404 |
@@ -386,8 +386,8 @@ Every connection the agent opens, in one place. **Guarded** means: the HTTP clie
|---|---|---|---|---|---|
| `api.osv.dev` (`/v1/querybatch`, `/v1/vulns/{id}`) | purls of SBOM components, advisory ids | `pipeline/cve.rs` | guarded | 10 s per request, 5 s connect, body ≤ 16 MiB, 8 advisory reads at once | none (CVE stage) |
| `services.nvd.nist.gov` (`/rest/json/cves/2.0`) | CVE ids (CVSS score), CPE product prefixes (CODESYS, embedded libraries) | `pipeline/cve.rs`, `pipeline/nvd_cpe.rs` | guarded | 30 s per request, 5 s connect, body ≤ 16 MiB, 3 retries after 6/12/24 s, answers cached 6 h | `NVD_API_KEY` (optional, raises NVD's rate limit) |
| `www.cisa.gov` (`/sites/default/files/feeds/known_exploited_vulnerabilities.json`) | nothing (a GET of the public catalog) | `pipeline/cve_enrichment.rs` | guarded | 10 s per request, 5 s connect, body ≤ 16 MiB; at most once a day (cached for all tenants) | `CVE_EXPLOIT_LOOKUP=false` |
| `api.first.org` (`/data/v1/epss`) | CVE ids of the alerts | `pipeline/cve_enrichment.rs` | guarded | as above, 50 CVE ids per request, 500 uncached CVEs and 2 min per scan; answers cached a day | `CVE_EXPLOIT_LOOKUP=false` |
| `raw.githubusercontent.com` (`/cisagov/kev-data/develop/known_exploited_vulnerabilities.json`), else `www.cisa.gov` (`/sites/default/files/feeds/known_exploited_vulnerabilities.json`) | nothing (a GET of the public KEV catalog) | `pipeline/cve_enrichment.rs` | guarded | 10 s per request, 5 s connect, body ≤ 16 MiB; at most once a day (cached for all tenants) | `CVE_EXPLOIT_LOOKUP=false` |
| `api.first.org` (`/data/v1/epss`) | CVE ids of the alerts | `pipeline/cve_enrichment.rs` | guarded | as above, 50 CVE ids per request, 500 uncached CVEs and 2 min per scan; answers cached a day per source (EPSS and Vulnrichment apart, so one that fails is asked again alone) | `CVE_EXPLOIT_LOOKUP=false` |
| `raw.githubusercontent.com` (`/cisagov/vulnrichment/develop/…`) | CVE ids of the alerts (in the path) | `pipeline/cve_enrichment.rs` | guarded | as above, 8 at once | `CVE_EXPLOIT_LOOKUP=false` |
| `api.nuget.org` (registration, catalog) | NuGet package ids and versions, not for ids a `nuget.config` routes to another feed | `pipeline/sbom/nuget_license.rs` | guarded | 10 s per request, 5 s connect, body ≤ 2 MiB, 8 at once, 60 s and 300 uncached packages per scan | `NUGET_LICENSE_LOOKUP=false` |
| `registry.npmjs.org` | npm package names and versions, not for a registry or scope `.npmrc`/`.yarnrc.yml` routes elsewhere | `pipeline/sbom/registry_license.rs` | guarded | as nuget.org (bounds per scan; answers cached for all tenants) | `REGISTRY_LICENSE_LOOKUP=false` |