Skip to content

fix(network): block requests to private IPs by default (SSRF protection)#1233

Merged
chaliy merged 2 commits intomainfrom
fix/issue-1176-ssrf-dns-rebinding
Apr 13, 2026
Merged

fix(network): block requests to private IPs by default (SSRF protection)#1233
chaliy merged 2 commits intomainfrom
fix/issue-1176-ssrf-dns-rebinding

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 11, 2026

Summary

Closes #1176

  • is_private_ip() checks all private/reserved ranges: 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, 100.64.0.0/10, ::1, fd00::/8, fe80::/10
  • NetworkAllowlist::block_private_ips(bool) builder method (default: true)
  • HTTP client pre-resolves DNS via tokio::net::lookup_host() and blocks private IPs before connecting
  • Direct IP URLs (e.g. http://127.0.0.1) are also checked

Test plan

  • test_is_private_ip_loopback — 127.x and ::1
  • test_is_private_ip_rfc1918 — 10.x, 172.16-31.x, 192.168.x
  • test_is_private_ip_link_local — 169.254.x including AWS metadata
  • test_is_private_ip_public — 8.8.8.8, 1.1.1.1 not blocked
  • test_is_private_ip_v6 — ::1, fd00::, fe80::
  • test_block_private_ips_default_true
  • test_block_private_ips_disabled

@chaliy chaliy force-pushed the fix/issue-1176-ssrf-dns-rebinding branch from 81bfa3e to 57ad30e Compare April 11, 2026 23:32
Closes #1176 — Adds is_private_ip() check and block_private_ips option
(default: true) to NetworkAllowlist. HTTP client pre-resolves DNS and
blocks connections to private/reserved IP ranges (127.0.0.0/8,
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, ::1,
fd00::/8, fe80::/10). Prevents SSRF via DNS rebinding.
@chaliy chaliy force-pushed the fix/issue-1176-ssrf-dns-rebinding branch from 57ad30e to 3a197a4 Compare April 12, 2026 03:10
The is_private_ip function and block_private_ips field were added but
not wired into the check() method. Now literal private IPs in URL
hostnames are blocked before pattern matching when block_private_ips
is enabled (default: true).

Closes #1176
@chaliy chaliy merged commit 75a148a into main Apr 13, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-1176-ssrf-dns-rebinding branch April 13, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sec(network): SSRF via DNS rebinding — allowlist checks hostname string, not resolved IP

1 participant