Uh oh!
There was an error while loading. Please reload this page.
Reject abbreviated forms of unsafe git options - #2168
Conversation
There was a problem hiding this comment.
Pull request overview
This PR strengthens GitPython’s unsafe-option guard (Git.check_unsafe_options) to also reject abbreviated long options (e.g. --upl for --upload-pack) and adds a clone regression test to cover abbreviated spellings that Git accepts.
Changes:
- Updated
Git.check_unsafe_optionsto treat any unambiguous long-option prefix of a blocked option as unsafe. - Added a clone regression test for abbreviated unsafe options (
--upl,--upload-pac,--conf).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
git/cmd.py | Extends unsafe-option detection to include long-option prefix abbreviations. |
test/test_clone.py | Adds regression coverage for abbreviated unsafe clone options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
5ed4f88 to
25c684bCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
0f9720e to
8b53090CompareThe prefix check could reject otherwise allowed one-letter short options when an unrelated blocked long option began with the same character. Keep exact matches for every spelling, but restrict prefix matching to explicit long options and multi-character kwargs. This addresses the review comment: single-letter short options and kwargs must not be treated as long-option abbreviations. It also adds coverage for abbreviated unsafe kwargs so both clone validation paths remain protected. Reviewd-by: Sebastian Thiel <sebastian.thiel@icloud.com>
GitPython blocks options such as --upload-pack/-u and --config/-c because they can execute arbitrary commands unless unsafe options are explicitly allowed. Git also accepts a short option with its value joined to the same token, including after clusterable flags. Forms such as -uVALUE, -fuVALUE, -cVALUE, and -vcVALUE could therefore bypass an exact-token check. Parse single-dash option tokens sufficiently to recognize blocked short options while preserving safe attached values such as -oupstream. Also distinguish clone multi-option values from bare kwargs so positional values are not treated as long-option abbreviations. This completes the option-validation hardening for GHSA-2f96-g7mh-g2hx. Reviewed-by: Sebastian Thiel <sebastian.thiel@icloud.com>
Uh oh!
There was an error while loading. Please reload this page.
Byron
commented
Jul 12, 2026
Merging even without all CI green, as the runs that finish already show that it's probably working. |
What
check_unsafe_optionsonly matched exact canonical names, so an abbreviated option like--uplslipped past the guard and reached git as--upload-pack— arbitrary command execution even withallow_unsafe_options=False.Fix
Reject an option when its canonical name is a prefix of any blocked option's name. Empty candidates (e.g. a bare
--) are skipped so they don't false-match.Test
Added a clone-path regression test covering
--upl,--upload-pac, and--conf. Existing unsafe-option tests still pass.Refers: GHSA-f2m5-q89v-8m67.