fix(security): optional SSRF egress guard for probes and webhooks - #49
Merged
Conversation
Address the SSRF finding: an authenticated user can point a probe or webhook at internal services or the cloud metadata endpoint. A monitoring tool legitimately reaches internal hosts, so this is an opt-in guard (`SSRF_BLOCK_PRIVATE`, default off) for multi-tenant deployments. - app/core/security/ssrf.py: `assert_target_allowed(host)` resolves the host (DNS, so a name mapping to an internal IP is caught) and, when the guard is on, rejects loopback / RFC1918 / link-local (incl. 169.254.169.254) / reserved / multicast. - All probe types (HTTP/TCP/SSL/PING/SNMP) and webhook delivery, plus the SNMP poller, check the target first; the HTTP probe also stops auto-following redirects when the guard is on (so a 30x can't bounce to an internal address). - Default off → single-user self-hosted monitoring of internal hosts is unchanged. Tests: internal-IP classification, the toggle (off allows, on blocks internal / allows public), and HTTP-probe + webhook blocking when enabled. Full suite 235 passed; ruff + mypy(strict) green.
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.
Pentest remediation — finding #1 (SSRF). Opt-in (
SSRF_BLOCK_PRIVATE, default off,since monitoring legitimately reaches internal hosts).
assert_target_allowed(host)resolves DNS and, when enabled, blocks loopback /RFC1918 / link-local (incl. cloud metadata 169.254.169.254) / reserved / multicast.
delivery; the HTTP probe also disables redirect-following when the guard is on.
Tests: IP classification, the toggle, and HTTP/webhook blocking. Full suite 235
passed; ruff + mypy(strict) green.