Skip to content

Fix: Mitigate Server-Side Request Forgery (SSRF) via Parser Differential#129

Merged
siddu-k merged 1 commit into
siddu-k:mainfrom
ArshVermaGit:main_3
May 28, 2026
Merged

Fix: Mitigate Server-Side Request Forgery (SSRF) via Parser Differential#129
siddu-k merged 1 commit into
siddu-k:mainfrom
ArshVermaGit:main_3

Conversation

@ArshVermaGit

Copy link
Copy Markdown
Contributor

Description

This PR addresses a critical Server-Side Request Forgery (SSRF) vulnerability in the /api/scripts/import_github endpoint.

Previously, the application validated external script URLs using urllib.parse.urlparse, but passed the raw, untrusted user string directly to urllib.request. Due to well-documented parser differentials between these two libraries, an attacker could craft complex URLs (using manipulated fragments, whitespace, or @ symbols) that urlparse would incorrectly validate as a GitHub domain, while urllib.request would resolve to an entirely different host (such as 127.0.0.1 or an internal metadata IP).

Resolved Issue

Resolves #128

Changes Made

  • URL Canonicalization: Modified the import_github endpoint to reconstruct a brand new, safe URL string using only the explicitly validated scheme, hostname, and path/query components extracted by urlparse.
  • The backend HTTP request now utilizes this reconstructed 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.com or raw.githubusercontent.com domains. Attackers can no longer bypass the validation logic to scan internal infrastructure or interact with local services.

Testing

  • Verified standard GitHub script imports function correctly.
  • Simulated an SSRF payload (e.g., https://github.com@127.0.0.1/). Confirmed the application correctly detects the malicious hostname and blocks the request with a 400 Bad Request prior to executing the network call.

@ArshVermaGit ArshVermaGit left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @siddu-k ! Issue #128 has been resolved. Please review the PR and merge it under GSSoC. Thanks!

@siddu-k siddu-k merged commit e1fe5bf into siddu-k:main May 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security Vulnerability: Server-Side Request Forgery (SSRF) via Parser Differential

2 participants