Block unsafe Git file and URL options#2193
Merged
Merged
Conversation
GHSA-3f7w-8rr8-f37f reports that caller-controlled options forwarded by IndexFile.checkout() and TagReference.create() can make Git write to or read from arbitrary filesystem paths. Add regression coverage proving the unsafe options are rejected by default while preserving the explicit allow_unsafe_options escape hatch. Reuse GitPython's existing option candidate normalization and unsafe-option guard at both public API boundaries. Git baseline: a23bace963d508bd96983cc637131392d3face18. Documentation/git-checkout-index.adoc defines --prefix as prepending an output path, and Documentation/git-tag.adoc defines -F/--file as reading a tag message from a file. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
GHSA-539m-9xh6-q6rr reports incomplete unsafe option lists for archive inputs and clone bundle URLs. Caller-controlled archive additions can expose or inject filesystem content, while clone --bundle-uri can dereference an additional caller-controlled URL. Extend the existing archive denylist with --add-file and --add-virtual-file, and the clone denylist with --bundle-uri. Regression coverage exercises archive kwargs plus both clone multi-option and keyword paths. Git baseline: a23bace963d508bd96983cc637131392d3face18. Documentation/git-archive.adoc defines --add-file/--add-virtual-file, and Documentation/git-clone.adoc defines --bundle-uri as fetching from the supplied URI. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
Byron
force-pushed
the
more-unsafe-options
branch
from
July 26, 2026 05:41
e7867e7 to
7a4f5dc
Compare
Byron
marked this pull request as ready for review
July 26, 2026 05:41
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens GitPython’s security posture by blocking additional unsafe filesystem-path and URL options across higher-level APIs by default, while preserving an explicit allow_unsafe_options=True opt-out for callers that need these capabilities.
Changes:
- Add unsafe-option gating to
IndexFile.checkout()(--prefix) andTagReference.create()(-F/--file), controlled byallow_unsafe_options. - Expand the existing unsafe-option denylists for
git archive(--add-file,--add-virtual-file) andgit clone(--bundle-uri). - Add/extend focused tests asserting unsafe options raise
UnsafeOptionError.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
git/repo/base.py |
Extends clone/archive unsafe option denylists to cover bundle URI and archive file-injection options. |
git/refs/tag.py |
Blocks tag message-from-file options by default in TagReference.create(), with an explicit opt-out. |
git/index/base.py |
Blocks checkout-index --prefix usage by default in IndexFile.checkout(), with an explicit opt-out. |
test/test_clone.py |
Adds clone tests covering --bundle-uri and bundle_uri being rejected by default. |
test/test_repo.py |
Adds archive tests covering add_file and add_virtual_file being rejected by default. |
test/test_refs.py |
Adds tests asserting TagReference.create() rejects -F/--file unless explicitly allowed. |
test/test_index.py |
Adds a test asserting IndexFile.checkout() rejects --prefix unless explicitly allowed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by
Codex GPT-5.Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Summary
Block unsafe filesystem-path and URL options in GitPython APIs by default while retaining the explicit
allow_unsafe_options=Trueopt-out.IndexFile.checkout()andTagReference.create().Advisory summaries
GHSA-3f7w-8rr8-f37f
GHSA-539m-9xh6-q6rr
Both advisories remain private, so exploit details are intentionally omitted here.
Validation
git diff --checkpassesGit behavior was checked against Git
a23bace963d508bd96983cc637131392d3face18and the relevantgit-checkout-index,git-tag,git-archive, andgit-clonedocumentation.