fix(sdk,openapi): block SSRF targets when fetching integration specs by URL - #1887
Open
ra-co88 wants to merge 1 commit into
Open
fix(sdk,openapi): block SSRF targets when fetching integration specs by URL#1887ra-co88 wants to merge 1 commit into
ra-co88 wants to merge 1 commit into
Conversation
ra-co88
force-pushed
the
fix/ssrf-egress-guard
branch
5 times, most recently
from
August 30, 2026 18:01
c9ca82c to
7836834
Compare
ra-co88
force-pushed
the
fix/ssrf-egress-guard
branch
from
August 30, 2026 18:23
7836834 to
8067ef3
Compare
Author
|
Heads-up on the red |
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.
What
Integration specs fetched by URL now pass an SSRF gate (
assertFetchable) before any request is made: the hostname is resolved, the address is classified, and only public targets are fetched — connecting to the pinned resolved address so DNS rebinding cannot swap the answer between validation and connect.Why
The spec URL is user-supplied. Without a gate it can target the loopback range, RFC1918 space, link-local addresses (including 169.254.169.254 cloud metadata), carrier-grade NAT, IPv6 link-local/ULA, IPv4-mapped IPv6, 0.0.0.0, or broadcast. The gate resolves first and classifies the address — not the hostname — then pins the connection to that address, closing both the plain SSRF and the DNS-rebinding variants (no second resolution between validate and connect).
The module deliberately carries no static
node:imports: it sits in the SDK barrel, which DOM-platform consumers typecheck against node-less libs. DNS loads lazily via a runtime-assembled specifier; IP classification is self-contained.What changed
assertFetchable(url)in the SDK: parse → scheme/userinfo checks → normalize (IP literals in any encoding) → resolve → classify → pin. The gate takes anallowLoopbackoption; the default stays fail-closed.http:URLs the fetch connects to the pinned address (Host header preserved). Forhttps:URLs the fetch keeps the original hostname — see Limitations.EXECUTOR_ALLOW_LOOPBACK_SPECS=1(spec-fetch-scoped) or the established local-network knobs —ALLOW_LOCAL_NETWORK=true(the cloud e2e harness already sets it) orEXECUTOR_ALLOW_LOCAL_NETWORK=true(selfhost e2e). Production never sets any of them.Limitations
Redirect chains are not followed by the gate: a public URL that 302s to a private address is blocked only if the fetch client itself refuses redirects (or re-validates). A follow-up making the fetch loop redirect-aware and re-running the gate per hop is the natural hardening step; this PR declares the gap rather than overclaiming.
For
https:URLs the fetch connects by hostname, not by the pinned address: fetch-based transports have no custom-connect hook, and rewriting an https URL to the resolved IP would present the IP as TLS SNI and break CDN-fronted hosts. The gate still decides the fetch (any blocked resolved address fails the target before the request), but the connect is not address-pinned on https — a re-resolve window between validate and connect remains there. Plain http fetches are address-pinned end to end.Test plan
Classification table (public allowed; every private/reserved encoding blocked, including integer/hex/octal IPv4 forms) plus resolve-and-pin tests with an injected resolver. 12 tests green against current main.