feat: Add probe target allowlist for /probe (SSRF and DNS rebinding hardening) - #1302
Open
adeptvin1 wants to merge 1 commit into
Open
feat: Add probe target allowlist for /probe (SSRF and DNS rebinding hardening)#1302adeptvin1 wants to merge 1 commit into
adeptvin1 wants to merge 1 commit into
Conversation
- Add --probe-target-allowlist and PG_EXPORTER_PROBE_TARGET_ALLOWLIST (CIDR and host:port); empty default keeps previous behavior - Harden allowlist checks against SSRF and DNS rebinding - Preserve sslmode=verify-full semantics when rewriting probe DSNs Signed-off-by: Ivan Filianin <adeptvin1@gmail.com>
Author
|
Good day! |
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.
Summary
Adds an optional allowlist for the multi-target
/probeendpoint so operators can restrict which hosts/IPs and ports the exporter may connect to. This mitigates SSRF-style abuse of an open/probeURL and hardens checks against DNS rebinding. When the allowlist is non-empty, resolved addresses must match CIDR and/or host:port entries.sslmode=verify-fullsemantics are preserved when the probe DSN is rewritten.Motivation
With
/probe?target=…, anyone who can reach the exporter can ask it to connect to arbitrary Postgres endpoints. In shared or less trusted networks this is risky. An explicit allowlist is a standard control for this pattern (similar to other multi-target exporters).Security context (Prometheus model)
The Prometheus security model notes that some exporters accept targets via URL parameters, so anyone who can reach the exporter’s HTTP endpoint may be able to make it connect to arbitrary endpoints. The multi-target
/probe?target=…pattern in postgres_exporter falls into that category.This change does not replace network controls, reverse proxies, authentication, or the general guidance not to expose monitoring HTTP to untrusted networks as the primary defense. It adds an optional, configuration-side restriction on where
/probemay connect, for operators who want extra control on top of their deployment model.Intended use
The feature is opt-in and off by default: an empty allowlist keeps existing behavior (all targets allowed). It is aimed mainly at deployments where the exporter is reachable from a broader or less trusted part of a corporate network (or similar), and operators still use
/probeinstead of a sidecar—only when they choose to constrain which Postgres endpoints may be probed through this instance.Behavior
--probe-target-allowlistPG_EXPORTER_PROBE_TARGET_ALLOWLISTCIDRand/orhost:port(for example10.0.0.0/8,db.example.com:5432)Implementation notes
verify-fullbehavior consistent with the connection path.Documentation and tests
probe_allowlist_test.go.