fix: strengthen fetch_url IP validation - #1126
Open
awhite0030 wants to merge 1 commit into
Open
Conversation
This commit unifies IP validation logic in fetch-url by extracting it into a `validateUrlInternal` function, which now properly inspects parsed `net.isIPv4` and `net.isIPv6` properties instead of strictly matching string prefixes. This closes vulnerabilities allowing loopback range bypasses (e.g. 127.0.0.2), IPv4-mapped IPv6 loopbacks, cloud metadata IP bypasses, and FQDNs with trailing dots. It also fixes the bug where valid domains starting with "10." were being falsely blocked.
awhite0030
requested review from
Avtrkrb,
akramcodez and
will-lamerton
as code owners
September 2, 2026 00:43
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.
Description
Brief description of what this PR does
Type of Change
Changeset
pnpm changeset) describing this change for the changelogDocs-only or internal chores need no changeset (or run
pnpm changeset --emptyto note that intentionally).Testing
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist
Root cause: The validation for
fetch_url's loopback and internal network check was relying on strict string matching for exact values (e.g.,127.0.0.1,localhost) rather than correctly analyzing the normalized hostname as an IPv4/IPv6 block. This allowed large portions of the loopback block (e.g.,127.0.0.2), cloud metadata targets, and IPv4-mapped IPv6 equivalents to bypass validation. Furthermore, validation was not performed at execution, meaning if it was skipped or bypassed, the IP was fetched regardless, while correctly resolving public domains like10.example.comwere falsely flagged.Fix: Replaced the ad-hoc string comparisons with a unified
validateUrlInternalhelper used in both the executor and validator. It strips trailing dots and leveragesnet.isIPv4andnet.isIPv6to correctly parse dotted quads and bracketed IP ranges. It now explicitly matches the entire127.0.0.0/8,169.254.0.0/16,10.0.0.0/8,172.16.0.0/12, and192.168.0.0/16networks, as well as equivalent IPv6 and IPv4-mapped formats. Since it restricts the range match to only valid IP addresses, it now correctly allows domains like10.example.com.Validation:
All commands ran and passed without errors, demonstrating validation rejects SSRF patterns and successfully compiles.
Fixes #1088
Fixes #1088