fix(apiserver): validate git URL scheme in GitSourceManager to prevent SSRF#588
Open
Joshua-Medvinsky wants to merge 1 commit into
Open
Conversation
…t SSRF Add scheme allowlist (https, http) in GitSourceManager._parse_source(). Non-HTTP/HTTPS schemes (file://, git://, ssh://) are now rejected with a ValueError before any network request is made. This prevents SSRF via cloud IMDS endpoints (http://169.254.169.254/), local filesystem access (file:///etc/), and internal git servers using non-standard protocols. Signed-off-by: FailSafe Researcher <joshua@getfailsafe.com> Signed-off-by: Joshua Medvinsky <joshuam33@Joshuas-MacBook-Pro.local>
|
Hi maintainers 👋 This vulnerability was found by FailSafe — a top agentic cybersecurity company specializing in automated deep security analysis of AI/ML and agentic codebases. We're reporting these initial findings as a social good contribution to help secure the open-source AI ecosystem. If you'd like us to perform a deeper, more comprehensive security scan of your project, we'd love to hear from you — reach out at joshua@getfailsafe.com. Thanks for maintaining this project! 🙏 |
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.
Problem
GitSourceManager._parse_source()passes the user-suppliedsource.locationvaluedirectly to
git.Repo.clone_from(url=...)without validating the URL scheme. Thisallows SSRF attacks via non-HTTPS schemes:
http://169.254.169.254/— cloud IMDS credential theft (AWS, GCP, Azure)file:///etc/— local filesystem access as git repositorygit://internal-host/— internal git server accessssh://user@internal/— internal SSH service probingExample attack:
Fix
Add scheme validation in
_parse_source()usingurllib.parse.urlparse. Onlyhttps://and
http://are allowed. Schemes likefile://,git://, andssh://raiseValueErrorbefore any network request is made.
http://is included to support legitimate internal/corporate git servers that use plain HTTP.Test Plan
https://URLs)file:///etcraisesValueErrorgit://internal/reporaisesValueErrorhttps://github.com/valid/repo.gitpasseshttp://internal-git/repo.gitpassesSecurity Note
CVSS 3.1: AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N = 8.5 (High)
This fix is independent of API authentication — it restricts what git URLs any caller
(authenticated or not) can supply to the deployment system.