Add SSRF protection to RemoteURL validation#4697
Merged
Conversation
ValidateRemoteURL now rejects URLs targeting internal and metadata endpoints to prevent SSRF vectors when downstream components fetch user-supplied URLs in-cluster. Blocked ranges: loopback (127.0.0.0/8, ::1), link-local/cloud metadata (169.254.0.0/16), RFC 1918 private (10/8, 172.16/12, 192.168/16), IPv6 ULA (fc00::/7), and the unspecified address (0.0.0.0/8, ::). IPv4-mapped IPv6 addresses (::ffff:127.0.0.1) are normalized to prevent bypass. Blocked hostnames: localhost, kubernetes.default.svc(.cluster.local), cluster.local, metadata.google.internal (with subdomain matching). The MCPServerEntry controller now calls ValidateRemoteURL and reports results through a RemoteURLValidated status condition, consistent with the existing MCPRemoteProxy controller pattern. Closes #4695 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4697 +/- ##
==========================================
+ Coverage 68.60% 68.64% +0.03%
==========================================
Files 515 515
Lines 53518 53572 +54
==========================================
+ Hits 36718 36772 +54
Misses 13958 13958
Partials 2842 2842 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ChrisJBurns
approved these changes
Apr 9, 2026
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
Cloud metadata, loopback, and private-range URLs in
RemoteURLfields couldbecome SSRF vectors if any downstream component fetches them in-cluster. The
existing validation only checked the URL scheme (
^https?://), leavinginternal endpoints wide open.
This extends
ValidateRemoteURLto reject well-known internal and metadataendpoints, and wires that validation into the MCPServerEntry controller (which
previously had no URL validation at all).
Closes #4695
Type of change
Test plan
task test)task lint-fix)Changes
cmd/thv-operator/pkg/validation/url_validation.gocmd/thv-operator/pkg/validation/url_validation_test.gocmd/thv-operator/api/v1alpha1/mcpserverentry_types.goRemoteURLValidatedcondition type and reason constantscmd/thv-operator/controllers/mcpserverentry_controller.govalidateRemoteURLstep to reconciler with status condition reportingcmd/thv-operator/controllers/mcpserverentry_controller_test.goSpecial notes for reviewers
::ffff:127.0.0.1is normalized viaTo4()before CIDR matching so it correctly hits IPv4 blocklists.169.254.169.254would bypass this. This is acceptable for admission-time validation; runtime fetch guards would need separate DNS-aware checks.ValidateRemoteURLatmcpremoteproxy_controller.go:369, so it gets the SSRF protection automatically with no code change.ValidateJWKSURLshould get the samevalidateHostNotInternalcheck (separate issue, different SSRF surface).Generated with Claude Code