Skip to content

Remove IPv4 ranges the SSRF guard's predicates already cover#2989

Open
djmb wants to merge 1 commit into
mainfrom
security/ssrf-guard-dedup-ipv4-ranges
Open

Remove IPv4 ranges the SSRF guard's predicates already cover#2989
djmb wants to merge 1 commit into
mainfrom
security/ssrf-guard-dedup-ipv4-ranges

Conversation

@djmb

@djmb djmb commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Follow-up to #2988, which expanded SsrfProtection::DISALLOWED_IP_RANGES to the full IANA special-use registry — but five of the added entries (10.0.0.0/8, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.168.0.0/16) duplicate the private?/loopback?/link_local? predicate checks that run right before the list scan in blocked_address?, so they can never be the deciding factor.

Fix

Trim the list to only the ranges the predicates don't catch. No behavior change — the existing tests asserting RFC1918/loopback/link-local addresses are blocked all still pass via the predicates.

Tests

bin/rails test test/models/ssrf_protection_test.rb → 25 tests, 0 failures.

Same cleanup applied to the once-campfire counterpart in basecamp/once-campfire#225 (80fdd44).

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.
Copilot AI review requested due to automatic review settings July 21, 2026 10:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a small follow-up to #2988 that simplifies SsrfProtection::DISALLOWED_IP_RANGES by removing IPv4 RFC1918/loopback/link-local ranges that are already blocked earlier via IPAddr predicate checks in disallowed_ipv4?, keeping behavior unchanged while reducing dead entries.

Changes:

  • Remove RFC1918, loopback, and link-local IPv4 ranges from DISALLOWED_IP_RANGES since they’re already covered by private?, loopback?, and link_local?.
  • Update the inline comment to reflect that DISALLOWED_IP_RANGES only needs to contain ranges not caught by those predicates.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +12
# IPv4 special-use ranges (RFC 5735/6890) not already covered by the
# private?/loopback?/link_local? predicates in #blocked_address?.
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.

2 participants