security: reject dash-prefixed revisions in RevParse#143
Merged
Conversation
A revision that starts with a dash is interpreted by "git rev-parse" as a command-line option rather than an object, allowing an authenticated user to inject options such as "--absolute-git-dir" through parameters meant for commit SHAs or branch references and leak internal server details to the error logs. The "--end-of-options" separator does not help here because "git rev-parse" does not honor it for revisions, so reject such input outright. RevParse is the single funnel for user-controlled revisions (CatFileCommit, blobs, trees, submodules), so the guard closes the whole class at one place.
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.
A revision that starts with a dash is interpreted by
git rev-parseas a command-line option rather than an object, allowing an authenticated caller to inject git options through parameters meant for commit SHAs or branch references.--end-of-optionsdoes not help here becausegit rev-parsedoes not honor it for revisions, so this rejects such input outright.RevParseis the single funnel for user-controlled revisions (CatFileCommit, blobs, trees, submodules), so the guard closes the whole class at one place.This is the v2 counterpart of #142.
Refs GHSA-mxrh-2rxr-6mqc.