Fix: Mitigate Server-Side Request Forgery (SSRF) via Parser Differential#129
Merged
Conversation
ArshVermaGit
commented
May 27, 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.
Description
This PR addresses a critical Server-Side Request Forgery (SSRF) vulnerability in the
/api/scripts/import_githubendpoint.Previously, the application validated external script URLs using
urllib.parse.urlparse, but passed the raw, untrusted user string directly tourllib.request. Due to well-documented parser differentials between these two libraries, an attacker could craft complex URLs (using manipulated fragments, whitespace, or@symbols) thaturlparsewould incorrectly validate as a GitHub domain, whileurllib.requestwould resolve to an entirely different host (such as127.0.0.1or an internal metadata IP).Resolved Issue
Resolves #128
Changes Made
import_githubendpoint to reconstruct a brand new, safe URL string using only the explicitly validatedscheme,hostname, andpath/querycomponents extracted byurlparse.safe_url, completely stripping out any injected tricks or credentials.Security Impact
By eliminating the parser differential, the backend is now guaranteed to only initiate requests to the exact IP addresses corresponding to the
github.comorraw.githubusercontent.comdomains. Attackers can no longer bypass the validation logic to scan internal infrastructure or interact with local services.Testing
https://github.com@127.0.0.1/). Confirmed the application correctly detects the malicious hostname and blocks the request with a400 Bad Requestprior to executing the network call.