Don't follow HTTP redirects off the scan target - #24
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
Header, stack, service, and web fetchers used urllib's default redirect following. A public target that 302s to metadata or RFC1918 made the agent connect there (scanner SSRF). Return the 3xx instead, matching LLM/SIEM/vuln_prober/takeover hardening. Co-authored-by: dmitryflynn <dmitryflynn@users.noreply.github.com>
This was referenced Aug 29, 2026
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.
Bug and impact
Target-facing HTTP fetchers (header audit, stack fingerprint, service probe, web fingerprint, HTTP auth enum) used
urllib.request.urlopen, which follows 3xx by default — including cross-host hops.Trigger: Scan an authorized public host with headers/stack/probe/full enabled. The host returns
302 Location: http://169.254.169.254/latest/meta-data/(or RFC1918). The agent connects to that destination. On a cloud VM this can pull IMDS into scan evidence (_body_snippet, fingerprints, "open" web-root findings).LLM URLs, SIEM, vuln_prober, takeover, and active validation already refuse redirects. These auditors did not.
Root cause
Incomplete hardening:
urlopenfollows redirects unless a customHTTPRedirectHandlerraises. The remaining fetchers never installed one.Fix
Shared
src/http_fetch.urlopen_no_redirectsurfaces 3xx asHTTPErrorand never fetches the Location. Existing HTTPError handlers already return that status/headers, so 302s are audited in place instead of chasing metadata.Validation
python3 -m pytest test_http_ssrf_redirect.py— 7 passed (local origin 302s to a second server; destination hit count stays 0; normal 200 still fetched).Related suites (
test_header_audit,test_probers,test_web_fingerprint,test_stack_fingerprint,test_service_enum,test_active_validation,test_security_hardening,test_takeover) — 220 passed.