Repository navigation
fix(readurls): block CGNAT/shared-address and multicast ranges in SSRF guard - #336
Merged
codelion merged 1 commit intoOct 10, 2026
Conversation
- Switch the guard from a private-range deny-list to a global-routability allow-list (not is_global), which additionally blocks CGNAT/shared space (100.64.0.0/10, e.g. Tailscale) that is neither private nor global - Keep an explicit multicast check (ipaddress marks globally-routable multicast ranges as is_global) - Fail closed when resolution returns no addresses - Document the residual DNS rebinding (TOCTOU) limitation in code and README - Add 3 tests: CGNAT blocked, multicast blocked, empty resolution blocked
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
Fills two gaps in #334 (merged in 4088efc) in the readurls SSRF guard. The hardened guard is a strict superset of the previous blocklist (verified), so no previously-blocked address becomes reachable.
Gap 1 — CGNAT / shared address space was reachable.
100.64.0.0/10(RFC 6598, including Tailscale's100.100.100.100and other CGNAT gateway services) was not on the blocklist and passed the old checks. The guard now rejects anything that is notip.is_globalor is multicast, instead of enumerating specific ranges — which also future-proofs it against other special-purpose ranges (RFC 1918/4193, loopback, link-local, documentation ranges, etc. remain covered viais_global).Gap 2 — empty
getaddrinforesults now fail closed. Previously, a resolver returning zero addresses could fall through and be treated as allowed; an empty result now raises and the request is refused.Known limitation
DNS rebinding remains a TOCTOU risk: the host is checked via
getaddrinfobefore the fetch, but the underlying HTTP client performs its own resolution and may observe a different answer. This limitation is now documented in the README, which recommends egress filtering for high-security deployments. A complete fix requires a pinned-IP transport layer; happy to follow up if maintainers want it.Testing
tests/test_readurls_ssrf.py: 22 passed (3 new cases covering CGNAT/shared ranges, multicast, and empty-resolution fail-closed behavior)tests/test_ssl_config.py+tests/test_plugins.py: 40 passed (regression)Refs #323.
Collaboration disclosure: This change was developed with AI assistance (human-reviewed).