fix(cve): OSV and NVD lookups go through guarded_net (#469) #476

Merged
sharang merged 1 commits from fix/469-cve-guarded-net into main 2026-10-05 23:15:13 +00:00
Owner

Closes #469.

Change

  • New compliance-agent/src/pipeline/public_http.rs (PublicHttp) follows the nuget_license pattern:
    • client from guarded_client_builder (approved addresses only, redirects re-checked, no proxy)
    • NetGuard::check_url before every request
    • 10 s per request, 5 s connect
    • bodies capped at 16 MiB (streamed, plus a Content-Length precheck)
  • CveScanner uses it for OSV querybatch and vulns/{id} and for NVD per-CVE requests, and so does nvd_cpe::product_cves for NVD CPE product queries. NVD requests keep the 30 s they had on the old shared client, because a product query returns up to 2,000 CVEs and NVD is slow without a key. A URL the guard refuses is not retried.
  • CveScanner::new(guard, nvd_api_key) -> Result<Self, CoreError> now takes the agent's NetGuard instead of a client. Callers:
    • orchestrator, scan and PLC paths: uses ?, so a client that can't be built fails the scan instead of falling back to a default client
    • CVE monitor in scheduler.rs: logs and skips
  • Removed:
    • search_context (SearXNG): dead code, and an internal SearXNG would now be refused anyway. SEARXNG_URL is left in core config as a deliberate leftover.
    • PipelineOrchestrator's http field and new parameter, which had no other user.

Audit of other reqwest clients in compliance-agent

Already guarded:

  • nuget.org (sbom/nuget_license.rs)
  • Gitea git source and tracker
  • DAST/pentest tools (compliance-dast)
  • git clones (check_git_url + resolved-address check)

Left on plain clients on purpose. These are operator-configured (env) and usually on the internal network, which the guard refuses by design:

  • LLM gateway (llm/, LITELLM_URL)
  • tenant registry (registry.rs)
  • OSCAL backend (controls/oscal_provider.rs, controls/scan_triage.rs)
  • GitLab/Jira trackers (GITLAB_URL, JIRA_URL)
  • pentest test-user cleanup (Keycloak/Auth0/Okta, pentest/cleanup.rs, pentest/orchestrator.rs)
  • headless Chrome for PDFs (pentest/report/pdf.rs, reqwest::get)

Subprocess egress (Syft remote license lookups, lockfile generation) goes over each tool's own HTTP and is documented, not guarded.

docs/reference/tools.md has a new "Outbound connections (egress)" section listing every destination, what is sent, the module, the guard, the limits and the switch.

Tests

  • cve::tests::osv_on_an_internal_address_is_refused: OSV stand-in on loopback with a public-only guard. The scan errors and no request arrives.
  • osv_answers_are_read_through_the_guarded_client: the same stand-in with allow_private works end to end.
  • nvd_cpe::tests::an_internal_address_is_refused_and_not_retried
  • public_http::tests: loopback, RFC 1918, link-local/metadata and IPv6 loopback are refused, and localhost never connects.
  • Redirect re-checking is covered in compliance-core::guarded_net.
  • Ran cargo fmt, cargo clippy -p compliance-agent --all-targets -D warnings and cargo test -p compliance-agent --lib.

Touches orchestrator.rs next to #474 (#460). It will be rebased after that merges.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Closes #469. ## Change - New `compliance-agent/src/pipeline/public_http.rs` (`PublicHttp`) follows the `nuget_license` pattern: - client from `guarded_client_builder` (approved addresses only, redirects re-checked, no proxy) - `NetGuard::check_url` before every request - 10 s per request, 5 s connect - bodies capped at 16 MiB (streamed, plus a `Content-Length` precheck) - `CveScanner` uses it for OSV `querybatch` and `vulns/{id}` and for NVD per-CVE requests, and so does `nvd_cpe::product_cves` for NVD CPE product queries. NVD requests keep the 30 s they had on the old shared client, because a product query returns up to 2,000 CVEs and NVD is slow without a key. A URL the guard refuses is not retried. - `CveScanner::new(guard, nvd_api_key) -> Result<Self, CoreError>` now takes the agent's `NetGuard` instead of a client. Callers: - orchestrator, scan and PLC paths: uses `?`, so a client that can't be built fails the scan instead of falling back to a default client - CVE monitor in `scheduler.rs`: logs and skips - Removed: - `search_context` (SearXNG): dead code, and an internal SearXNG would now be refused anyway. `SEARXNG_URL` is left in core config as a deliberate leftover. - `PipelineOrchestrator`'s `http` field and `new` parameter, which had no other user. ## Audit of other `reqwest` clients in compliance-agent Already guarded: - nuget.org (`sbom/nuget_license.rs`) - Gitea git source and tracker - DAST/pentest tools (`compliance-dast`) - git clones (`check_git_url` + resolved-address check) Left on plain clients on purpose. These are operator-configured (env) and usually on the internal network, which the guard refuses by design: - LLM gateway (`llm/`, `LITELLM_URL`) - tenant registry (`registry.rs`) - OSCAL backend (`controls/oscal_provider.rs`, `controls/scan_triage.rs`) - GitLab/Jira trackers (`GITLAB_URL`, `JIRA_URL`) - pentest test-user cleanup (Keycloak/Auth0/Okta, `pentest/cleanup.rs`, `pentest/orchestrator.rs`) - headless Chrome for PDFs (`pentest/report/pdf.rs`, `reqwest::get`) Subprocess egress (Syft remote license lookups, lockfile generation) goes over each tool's own HTTP and is documented, not guarded. `docs/reference/tools.md` has a new "Outbound connections (egress)" section listing every destination, what is sent, the module, the guard, the limits and the switch. ## Tests - `cve::tests::osv_on_an_internal_address_is_refused`: OSV stand-in on loopback with a public-only guard. The scan errors and no request arrives. - `osv_answers_are_read_through_the_guarded_client`: the same stand-in with `allow_private` works end to end. - `nvd_cpe::tests::an_internal_address_is_refused_and_not_retried` - `public_http::tests`: loopback, RFC 1918, link-local/metadata and IPv6 loopback are refused, and `localhost` never connects. - Redirect re-checking is covered in `compliance-core::guarded_net`. - Ran `cargo fmt`, `cargo clippy -p compliance-agent --all-targets -D warnings` and `cargo test -p compliance-agent --lib`. Touches `orchestrator.rs` next to #474 (#460). It will be rebased after that merges. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-10-05 22:56:26 +00:00
fix(cve): OSV and NVD lookups go through guarded_net (#469)
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 10m50s
96ed730ffe
The CVE scanner asked api.osv.dev (querybatch, vulns/{id}) and NVD (per
CVE, per CPE product) with the agent's plain HTTP client. Every other
outbound call to an address the agent does not fully control is already
guarded, and since #468 the nuget.org license lookup is too.

New pipeline/public_http.rs (PublicHttp), the nuget_license pattern:
a guarded_client_builder client (approved addresses only, redirects
re-checked, no proxy), NetGuard::check_url before every request, 10 s
per request, 5 s connect, bodies capped at 16 MiB. CveScanner and
nvd_cpe::product_cves use it. NVD requests keep 30 s, as on the old
shared client (a product query returns up to 2,000 CVEs). A URL the
guard refuses is not retried.

CveScanner::new takes the agent's NetGuard instead of a client. The
dead search_context (SearXNG) is removed: it was never called, and an
internal SearXNG would be refused by the guard anyway. The orchestrator's
http field had no other user and is gone.

Audited every other reqwest client in compliance-agent. The LLM gateway,
tenant registry, OSCAL backend, GitLab/Jira trackers, identity providers
(pentest cleanup) and headless Chrome are operator-configured and often
internal, so they stay on plain clients. docs/reference/tools.md now
lists all egress in one place.

Tests: the OSV stand-in on loopback is refused with a public-only guard
(no request reaches it) and answers with allow_private. An NVD product
query to loopback is refused and not retried. check_url refuses
loopback, RFC 1918, link-local and metadata addresses, and a name that
resolves to loopback is refused when connecting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang force-pushed fix/469-cve-guarded-net from e5244e47b1 to 96ed730ffe 2026-10-05 22:56:26 +00:00 Compare
sharang merged commit 5fdf80a1e0 into main 2026-10-05 23:15:13 +00:00
Sign in to join this conversation.