Skip to content

Commit aca595c

Browse files
committed
Remove IPv4 ranges the IPAddr predicates already cover
The RFC1918, loopback, and link-local ranges in DISALLOWED_IP_RANGES duplicated the private?/loopback?/link_local? checks that run right before the list scan, so they could never be the deciding factor. Keep only the ranges the predicates don't catch.
1 parent d3a3998 commit aca595c

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

app/models/ssrf_protection.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@ module SsrfProtection
88
8.8.8.8
99
]
1010

11-
# IPv4 ranges that must never be a fetch target (RFC 5735/6890 special-use,
12-
# plus CGNAT and benchmarking). RFC1918/loopback/link-local are also covered
13-
# by the IPAddr predicates in #blocked_address?.
11+
# IPv4 special-use ranges (RFC 5735/6890) not already covered by the
12+
# private?/loopback?/link_local? predicates in #blocked_address?.
1413
DISALLOWED_IP_RANGES = [
1514
IPAddr.new("0.0.0.0/8"), # "This" network (RFC1700)
16-
IPAddr.new("10.0.0.0/8"), # Private (RFC1918)
1715
IPAddr.new("100.64.0.0/10"), # Carrier-grade NAT (RFC6598)
18-
IPAddr.new("127.0.0.0/8"), # Loopback
19-
IPAddr.new("169.254.0.0/16"), # Link-local (incl. AWS metadata)
20-
IPAddr.new("172.16.0.0/12"), # Private (RFC1918)
2116
IPAddr.new("192.0.0.0/24"), # IETF protocol assignments (RFC6890)
2217
IPAddr.new("192.0.2.0/24"), # TEST-NET-1 (RFC5737)
2318
IPAddr.new("192.88.99.0/24"), # 6to4 relay anycast (RFC7526)
24-
IPAddr.new("192.168.0.0/16"), # Private (RFC1918)
2519
IPAddr.new("198.18.0.0/15"), # Benchmark testing (RFC2544)
2620
IPAddr.new("198.51.100.0/24"), # TEST-NET-2 (RFC5737)
2721
IPAddr.new("203.0.113.0/24"), # TEST-NET-3 (RFC5737)

0 commit comments

Comments
 (0)