Add: Opt-in endpoint hardening (auth, health IP allow-list, declined-response headers)#2249
Open
mde-gb wants to merge 3 commits into
Open
Add: Opt-in endpoint hardening (auth, health IP allow-list, declined-response headers)#2249mde-gb wants to merge 3 commits into
mde-gb wants to merge 3 commits into
Conversation
Co-authored-by: AI (codex/partial)
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned Files
|
There was a problem hiding this comment.
Pull request overview
This PR adds opt-in hardening controls for openvasd endpoints: optional authentication enforcement for Notus/VT routes, optional IP allow-listing for health probes based on direct TCP peer address, and optional suppression of metadata headers on declined (401/403) responses.
Changes:
- Introduces
[endpoints]settings and corresponding CLI/env/config plumbing forrequire_authentication,health_ip_allowlist, andhide_declined_response_headers. - Threads peer
SocketAddrinto request handling to enforce health allow-listing and centralizes “hide declined headers” logic in the framework entry point. - Updates OpenAPI, README, example configs, config snapshots, and adds tests for the new behaviors.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/src/openvasd/README.md | Documents new endpoint hardening options and CLI flags. |
| rust/src/openvasd/notus/mod.rs | Makes Notus handlers optionally require authentication and adds tests. |
| rust/src/openvasd/main.rs | Wires new endpoint policy/auth settings into runtime initialization and adds fail-fast validation. |
| rust/src/openvasd/config/snapshots/openvasd__config__tests__defaults.snap | Updates default config snapshot for new fields. |
| rust/src/openvasd/config/mod.rs | Adds new endpoints config fields, TOML validation/serde for allow-list, CLI/env flags, and tests. |
| rust/examples/openvasd/config.example.toml | Documents new [endpoints] options in example config. |
| rust/examples/openvasd/config.example_v1.toml | Documents new [endpoints] options in example v1 config. |
| rust/crates/greenbone-scanner-framework/src/lib.rs | Adds endpoint policy plumbing, peer forwarding into services, and threads “require auth” into VT handler registration. |
| rust/crates/greenbone-scanner-framework/src/get_vts.rs | Adds optional authentication requirement to /vts handler and tests. |
| rust/crates/greenbone-scanner-framework/src/entry/mod.rs | Implements EndpointPolicy (health allow-list + hide headers), enforces allow-list for health routes, and hides metadata headers on 401/403 when configured. |
| rust/crates/greenbone-scanner-framework/Cargo.toml | Adds cidr dependency for allow-list CIDR matching. |
| rust/Cargo.toml | Moves cidr to workspace dependency and consumes it via workspace. |
| rust/Cargo.lock | Updates lockfile for dependency graph changes. |
| rust/api/openapi.yml | Updates health paths and documents new 401/403 behaviors for affected routes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review feedback on the unreleased endpoint-auth/health-allowlist feature. No user-visible behavior change, so this stays a non-escalating Refactor (the PR's Add: merge already covers the feature). - config: validate --health-ip-allowlist via clap value_parser!(IpInet) instead of panicking at parse time; collect parsed values directly. - config: keep serialize signature as &[IpInet] and add #[serde(default)] on Endpoints.enable_get_scans. - framework: fix clippy::op_ref in is_health_probe_route. - notus: rename internal Get/PostOSIcnomingRequest -> ...IncomingRequest typo. - openapi: document 503 Service Unavailable on the HEAD health probes. Co-authored-by: AI (copilot/partial)
Document that openvasd refuses to start when require_authentication is enabled without an API key or complete mTLS configuration, and describe the current declined-response header behaviour instead of changes over time. Co-authored-by: AI (copilot/full)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds three opt-in
[endpoints]settings toopenvasd, all defaulting to off soexisting deployments are unaffected:
require_authentication— require the configured auth (mTLS or API key) for/notus,/notus/{os}, and/vts(previously always unauthenticated).health_ip_allowlist— restrict the implemented health probe routes(
GET/HEADon/health/alive,/health/ready,/health/started) to directTCP peer IPs or CIDR networks.
X-Forwarded-Foris intentionally ignored.hide_declined_response_headers— omit theauthentication,api-version, andfeed-versionmetadata headers on401and403responses.Each is configurable via TOML, CLI flag, and environment variable. Startup fails
fast if
require_authenticationis set without an API key or complete mTLS config.OpenAPI, README, example configs, the default config snapshot, and tests are updated.
Why
Today
openvasdserves the Notus and VT endpoints without authentication andanswers health probes for any caller. That is acceptable behind a trusted gateway,
but risky for any instance that is — intentionally or accidentally — reachable from
an untrusted network. This change lets operators harden such deployments without
breaking the default behavior.
Concrete risks on a publicly reachable instance:
vulnerability tests the scanner knows about. An attacker can fingerprint the
feed and OS coverage to infer what the operator can (and cannot) detect, and use
that to plan evasion. These endpoints are also comparatively expensive, so open
access invites resource abuse and denial-of-service amplification.
/health/alive,/health/ready,/health/started)leak liveness and readiness state. That confirms a live service to scanners and
helps an attacker time activity (e.g., probe while the service is starting or
not ready) and map infrastructure during reconnaissance.
authentication,api-version, andfeed-versionon401/403responses hands version andcapability details to callers who have not authenticated. This is information
disclosure / version fingerprinting — OWASP A02:2025 Security Misconfiguration —
and contradicts the least-information and defense-in-depth principles. Precise
api-version/feed-versionvalues let an attacker correlate the instance withknown issues in specific versions (cf. OWASP WSTG information-gathering / version
disclosure). Suppressing them on declined responses reduces the pre-auth
attack surface while keeping the headers available to authenticated clients.
Because every option defaults to off, current setups are unchanged; operators opt
in only where the threat model requires it.
How
EndpointPolicyingreenbone-scanner-frameworkholds the allow-list and thehide-headers flag.
allows_health_peermatches the peer IP against the CIDR set;is_health_probe_routegates only the implemented health routes; metadata-headersuppression is centralized in
should_hide_metadata_headers.SocketAddrthroughmake_serviceinto theentry point so the allow-list can be enforced per connection.
GetVTsHandler, Notus handlers) gain arequire_authenticationflag threaded through
RuntimeBuilder(newapi_key,endpoint_policy, andrequire_authenticationbuilder methods).IpInet) and rejects invalid valuesfor both TOML and CLI input.
Contribution checklist
Add:→ minor release)Co-authored-by: AI (codex/partial)andCo-authored-by: AI (copilot/partial))file is nonetheless required, it is covered by Add: Exact client certificate pinning for openvasd mTLS #2248.