Skip to content

security: reject dash-prefixed revisions in RevParse#143

Merged
unknwon merged 1 commit into
v2from
jc/v2-revparse-dash-guard
Jul 17, 2026
Merged

security: reject dash-prefixed revisions in RevParse#143
unknwon merged 1 commit into
v2from
jc/v2-revparse-dash-guard

Conversation

@unknwon

@unknwon unknwon commented Jul 17, 2026

Copy link
Copy Markdown
Member

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 caller to inject git options through parameters meant for commit SHAs or branch references.

--end-of-options does not help here because git rev-parse does not honor it for revisions, so this rejects 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 is the v2 counterpart of #142.

Refs GHSA-mxrh-2rxr-6mqc.

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.
@unknwon
unknwon requested a review from a team as a code owner July 17, 2026 03:07
@unknwon
unknwon merged commit ce97c6e into v2 Jul 17, 2026
4 checks passed
@unknwon
unknwon deleted the jc/v2-revparse-dash-guard branch July 17, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant