fix: block joined short unsafe clone options#2162
Closed
Byron wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens GitPython’s unsafe-option detection for clone by ensuring short options with joined/attached values (e.g. -u/tmp/helper, -cprotocol.ext.allow=always) are canonicalized correctly during unsafe-option checks, closing a bypass described in GHSA-v396-v7q4-x2qj.
Changes:
- Update
Git._canonicalize_option_nameto normalize joined short options to their single-letter form for unsafe-option matching. - Add regression tests ensuring joined
-u...and-c...forms are rejected inRepo.cloneandRepo.clone_from. - Add canonicalization-focused assertions in the
Git.check_unsafe_optionsnormalization tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
git/cmd.py |
Canonicalizes short -xVALUE option tokens to x for unsafe-option checks, preventing bypass via joined short options. |
test/test_clone.py |
Adds regression cases for joined -u... and -c... in clone-related unsafe-option tests. |
test/test_git.py |
Adds direct check_unsafe_options cases asserting joined short options normalize to the expected unsafe keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d533b1c to
2568f2b
Compare
Member
Author
|
Actually, this might be a partial implementation of #2161, which also mentions how short options can be concatenated to hide the actual option. |
Member
Author
|
Closing based on this discovery. |
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.
Tasks
Advisory
Changes
Git._canonicalize_option_name, so inputs like-u/tmp/helperand-cprotocol.ext.allow=alwaysare correctly classified as-uand-c.-u...and-c...bypass forms intest_clone_unsafe_optionsandtest_clone_from_unsafe_options.test_check_unsafe_options_normalizes_kwargs.Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Validation
gh pr checks 2162 --watchcompleted successfully (latest run on this PR head).2568f2b7.