fix(provider-utils): harden SSRF protection with missing RFC-defined private IP ranges#14132
Open
Diode11-Alt wants to merge 1 commit intovercel:mainfrom
Open
fix(provider-utils): harden SSRF protection with missing RFC-defined private IP ranges#14132Diode11-Alt wants to merge 1 commit intovercel:mainfrom
Diode11-Alt wants to merge 1 commit intovercel:mainfrom
Conversation
…anges Add coverage for several RFC-defined private/reserved IPv4 ranges that were missing from the SSRF validation, which could allow attackers to reach internal cloud infrastructure: - 100.64.0.0/10 (Shared Address Space / CGNAT - RFC 6598) Used in AWS VPCs and cloud provider NAT gateways. An attacker could use this range to reach internal cloud services. - 198.18.0.0/15 (Benchmarking - RFC 2544) Reserved for network benchmarking, should never be routable externally. - 192.0.0.0/24 (IETF Protocol Assignments - RFC 6890) - 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 (Documentation - RFC 5737) - 240.0.0.0/4 (Reserved for Future Use - RFC 1112) Includes 255.255.255.255 (broadcast). Also blocks .internal domains (e.g., metadata.google.internal) which are used by GCP for cloud metadata access. Added comprehensive tests for all new ranges including boundary checks.
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
Hardens the SSRF protection in
validateDownloadUrl()by adding coverage for several RFC-defined private/reserved IPv4 ranges and cloud-internal hostnames that were missing from the blocklist.Security Impact
The current implementation blocks common private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 169.254.0.0/16) but misses several additional ranges defined in IANA's Special-Purpose Address Registry that could be exploited in cloud environments:
Missing IPv4 Ranges (Now Blocked)
100.64.0.0/10198.18.0.0/15192.0.0.0/24192.0.2.0/24198.51.100.0/24203.0.113.0/24240.0.0.0/4255.255.255.255broadcast.Missing Hostname Pattern (Now Blocked)
.internalmetadata.google.internal) resolves to169.254.169.254. While the IP is already blocked, hostname-based requests bypass IP checks when DNS resolution happens after validation (TOCTOU).Root Cause
The
isPrivateIPv4()function only covered the "classic" RFC 1918 ranges plus link-local. The IANA Special-Purpose Address Registry (RFC 6890) defines additional ranges that are not globally reachable and should be blocked in SSRF contexts.The
100.64.0.0/10range is particularly dangerous because it's actively used by cloud providers (AWS, GCP, Azure) for internal networking — an attacker could use it to probe VPC-internal services, NAT gateways, or other shared infrastructure.Changes
packages/provider-utils/src/validate-download-url.ts100.64.0.0/10,198.18.0.0/15,192.0.0.0/24,192.0.2.0/24,198.51.100.0/24,203.0.113.0/24, and240.0.0.0/4toisPrivateIPv4().internalto the blocked hostname patterns (alongside existing.local,.localhost)packages/provider-utils/src/validate-download-url.test.ts.internaldomain blocking::ffff:100.64.x.x(CGNAT via IPv4-mapped IPv6 bypass)Verification
100.64.0.1→ BLOCKED (inside CGNAT)100.63.255.255→ ALLOWED (below CGNAT range)100.128.0.1→ ALLOWED (above CGNAT range)198.18.0.1→ BLOCKED (benchmarking)198.17.0.1→ ALLOWED (below benchmarking range)Checklist