Skip to content

security: harden RevParse and pass --end-of-options across git commands#142

Merged
unknwon merged 2 commits into
masterfrom
jc/revparse-dash-guard
Jul 17, 2026
Merged

security: harden RevParse and pass --end-of-options across git commands#142
unknwon merged 2 commits into
masterfrom
jc/revparse-dash-guard

Conversation

@unknwon

@unknwon unknwon commented Jul 17, 2026

Copy link
Copy Markdown
Member

Two changes:

  1. RevParse guard (the fix). 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.

  2. Parity hardening (defense-in-depth). Bring master up to parity with the v2 branch by adding the --end-of-options separator to the remaining commands that accept it: checkout, reset, fetch, pull, commit, count-objects, fsck, for-each-ref, ls-tree, remote, tag, archive, show (blob), receive-pack, upload-pack, and update-server-info.

The v2 counterpart of the guard is #143.

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.
Bring the master branch up to parity with v2 by adding the
"--end-of-options" separator to the remaining commands that accept it:
checkout, reset, fetch, pull, commit, count-objects, fsck, for-each-ref,
ls-tree, remote, tag, archive, show (blob), receive-pack, upload-pack, and
update-server-info. This hardens them against argument injection as a
defense-in-depth measure.
@unknwon unknwon changed the title security: reject dash-prefixed revisions in RevParse security: harden RevParse and pass --end-of-options across git commands Jul 17, 2026
@unknwon
unknwon merged commit 4c38315 into master Jul 17, 2026
4 checks passed
@unknwon
unknwon deleted the jc/revparse-dash-guard branch July 17, 2026 03:19
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