fix: block SSRF in fetchSpec and GraphQL introspection#6
Open
karthikmudaliarX wants to merge 1 commit into
Open
fix: block SSRF in fetchSpec and GraphQL introspection#6karthikmudaliarX wants to merge 1 commit into
karthikmudaliarX wants to merge 1 commit into
Conversation
User-supplied URLs were fetched without validation, allowing requests to reach internal services (AWS metadata at 169.254.169.254, localhost, RFC 1918 ranges, etc.). Adds internal/urlutil.ValidatePublicURL which: - Rejects non-http/https schemes - Resolves the hostname via DNS - Rejects any address that falls within loopback, link-local, private RFC 1918, shared address space, multicast, or other reserved ranges Called before the HTTP fetch in cmd/add.go (fetchSpec) and before the POST in internal/graphql/introspect.go (Introspect).
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
aurl add <name> <url>andaurl add --graphql <name> <endpoint>both fetched user-supplied URLs without any validation, making them vulnerable to SSRF. An attacker who controls the URL (e.g. via a malicious README, a CI pipeline that passes untrusted input, or an AI agent acting on a crafted prompt) could point them at internal services:169.254.169.254)localhost/127.0.0.1(databases, admin panels, local services)10.x,172.16–31.x,192.168.x)Fix
Adds
internal/urlutil.ValidatePublicURL(rawURL string) errorwhich:httporhttpsValidatePublicURLis called before the HTTP fetch infetchSpec()(cmd/add.go) and before the POST inIntrospect()(internal/graphql/introspect.go).Ranges blocked
127.0.0.0/8,::1/128169.254.0.0/1610.0.0.0/8,172.16.0.0/12,192.168.0.0/16100.64.0.0/100.0.0.0/8192.0.0.0/24198.18.0.0/15198.51.100.0/24,203.0.113.0/24224.0.0.0/4,ff00::/8240.0.0.0/4fc00::/7fe80::/10