Repository navigation
fix(repo): protect against --reference and --reference-if-able when cloning - #2348
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The added unsafe options lack regression tests for clone() and clone_from() across keyword arguments, multi_options, and abbreviated spellings, including verification that allow_unsafe_options=True still permits valid reference-based clones.
1 open issue
What changed in this PR
GitHub Copilot reviewed this focused change to GitPython’s clone safety checks, requiring explicit opt-in for caller-controlled reference repositories.
Changes:
- Add
--referenceand--reference-if-ableto the unsafe clone options list. - Record the related security advisory in the changelog.
| File | Description |
|---|---|
git/repo/base.py |
Block reference-based clone options unless explicitly allowed. |
doc/source/changes.rst |
Add the related security advisory link. |
Review effort: Balanced
Byron
force-pushed
the
repo-clone-options
branch
from
November 16, 2026 04:25
e266f2e to
ee91408
Compare
<!-- agent --> This change follows the clone safety issue recorded in https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-j8pf-7m8v-xx38. Passing unchecked clone keyword arguments can make Git read objects from a caller-controlled local repository, which is surprising for callers that rely on GitPython's default unsafe-option restrictions. Add `--reference` and `--reference-if-able` to `Repo.unsafe_git_clone_options`, requiring `allow_unsafe_options=True` for these options. The shared clone guard also rejects abbreviated spellings and options supplied through `multi_options`. Record the advisory in `doc/source/changes.rst`. Copilot requested: "Please add regression cases for both `clone()` and `clone_from()`, covering keyword arguments and `multi_options` (including abbreviated spellings), and verify that `allow_unsafe_options=True` still permits valid reference-based clones." Extend the existing rejection cases and add local reference clones through both APIs, using keyword arguments and joined or split `multi_options`. The opt-in cases check the recorded alternate object store and read committed content, including a reference path containing spaces. Initial repositories are generated by the existing shell fixture rather than using the source checkout's history. Co-authored-by: Jeroen <jpab.eemsterboer@gmail.com> Co-authored-by: GPT 6.1 Sol <codex@openai.com> Assisted-by: GPT 6.1 Sol
Byron
force-pushed
the
repo-clone-options
branch
from
November 16, 2026 06:02
ee91408 to
b056f39
Compare
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
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
This work follows GHSA-j8pf-7m8v-xx38: applications passing unchecked clone options can unexpectedly let Git read objects from a caller-controlled local repository.
Require
allow_unsafe_options=Truefor--referenceand--reference-if-ablein bothRepo.clone()andRepo.clone_from(). The existing safety guard covers keyword arguments,multi_options, and abbreviated spellings. Record the advisory in the changelog.Regression coverage checks rejection through both APIs and verifies that explicit opt-in still creates valid reference clones, reads committed objects, and records the requested alternate object store. The opt-in cases cover keyword arguments, joined and split
multi_options, an accepted abbreviation, and paths containing spaces.Validation: all 59 non-network clone tests passed on each of the CLI and Gix backends. Both rejection tests failed when the new safeguards were removed in memory. Ruff lint/format checks, ShellCheck, Bash syntax checking, and
git diff --checkpassed.