Fix SSRF vulnerability in CannedScriptExecutionAction#3085
Open
Senthil455 wants to merge 1 commit into
Open
Conversation
Add URL validation to prevent Server-Side Request Forgery (SSRF) attacks. The url parameter is now validated before making outbound connections: - Only HTTPS URLs are allowed (enforced by schema check + HttpsURLConnection) - Block known internal hostnames (localhost, metadata.google.internal, kubernetes services, etc.) - Block loopback addresses (127.0.0.1, ::1) - Block private/site-local addresses (10.x.x.x, 172.16-31.x.x, 192.168.x.x) - Block link-local addresses (169.254.x.x, fe80::) - Block IPv4-compatible IPv6 addresses - Block the unspecified address (0.0.0.0, ::) This prevents attackers from using the action as a proxy to access internal services, cloud metadata endpoints, or other private network resources, even with admin-level authentication. Fixes google#3011
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.
This PR fixes a Server-Side Request Forgery (SSRF) vulnerability in
CannedScriptExecutionActionwhere theurlparameter was attacker-controlled and directly used to create an outboundHttpsURLConnectionwithout any validation, filtering, or allowlisting.Vulnerability Details
The
urlparameter (@Parameter("url") String urlat line 58) was fully user-controlled and passed directly toUrlConnectionService.createConnection(new URL(url))without validation. The server performed the request, read the full response viaUrlConnectionUtils.getResponseBytes(connection), and returned it to the caller inresponse.setPayload(). This effectively turned the application into an open proxy, enabling attackers to:*.svc.cluster.local)Root Cause
Lack of input validation and absence of network-level restrictions (e.g., blocking private IP ranges, internal hostnames) allowed arbitrary outbound HTTPS connections initiated by user input.
Fix
Added
validateUrl()method that enforces the following restrictions before any connection is made:https://URLs are accepted (consistent with the existingHttpsURLConnectioncast)BLOCKED_HOSTS), including:localhostmetadata,metadata.google.internalkubernetes,kubernetes.default,kubernetes.default.svc.cluster.localInetAddress.getByName()and the following address types are blocked:127.0.0.1,::1)10.x.x.x,172.16-31.x.x,192.168.x.x)169.254.x.x,fe80::)0.0.0.0,::)The fix also replaces the temporary email-debugging code (introduced in Verify user can send email #3045 and More debugging code for replyTo address #3053, which were explicitly marked as temporary) with the restored URL-fetching functionality that now includes SSRF protection.
Testing
validateUrl()method covers all known private/internal IP ranges and common internal hostnamesImpact
AUTH_ADMIN)/_dr/task/executeCannedScript?url=<attacker-controlled>Auth.AUTH_ADMIN— service accounts / admin users)Fixes SSRF in CannedScriptExecutionAction (Admin-Only) #3011
This change is