Skip to content

Block unsafe Git file and URL options#2193

Merged
Byron merged 3 commits into
mainfrom
more-unsafe-options
Jul 26, 2026
Merged

Block unsafe Git file and URL options#2193
Byron merged 3 commits into
mainfrom
more-unsafe-options

Conversation

@Byron

@Byron Byron commented Jul 26, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

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=True opt-out.

  • Guard filesystem-path options forwarded by IndexFile.checkout() and TagReference.create().
  • Extend the existing archive denylist for caller-controlled additions.
  • Extend the existing clone denylist for caller-controlled bundle URLs.

Advisory summaries

GHSA-3f7w-8rr8-f37f

  • Advisory: GHSA-3f7w-8rr8-f37f
  • Severity: High
  • Package/range: GitPython (pip), <= 3.1.55
  • Patched versions: not yet assigned
  • CVE: not yet assigned

GHSA-539m-9xh6-q6rr

  • Advisory: GHSA-539m-9xh6-q6rr
  • Severity: Medium
  • Package/range: GitPython (pip), <= 3.1.55
  • Patched versions: not yet assigned
  • CVE: not yet assigned

Both advisories remain private, so exploit details are intentionally omitted here.

Validation

  • Focused security tests for both commits pass
  • Touched-file Ruff check and format check pass
  • git diff --check passes
  • Broader affected-module runs pass the changed paths; remaining failures are unrelated legacy fixture/default-branch assumptions

Git behavior was checked against Git a23bace963d508bd96983cc637131392d3face18 and the relevant git-checkout-index, git-tag, git-archive, and git-clone documentation.

@Byron Byron changed the title Block unsafe checkout-index and tag file options Block unsafe Git file and URL options Jul 26, 2026
codex and others added 2 commits July 26, 2026 07:37
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
Byron force-pushed the more-unsafe-options branch from e7867e7 to 7a4f5dc Compare July 26, 2026 05:41
@Byron
Byron marked this pull request as ready for review July 26, 2026 05:41
Copilot AI review requested due to automatic review settings July 26, 2026 05:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and TagReference.create() (-F/--file), controlled by allow_unsafe_options.
  • Expand the existing unsafe-option denylists for git archive (--add-file, --add-virtual-file) and git 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.

Comment thread git/repo/base.py Outdated
Comment thread test/test_refs.py
Copilot AI review requested due to automatic review settings July 26, 2026 07:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@Byron
Byron merged commit d1a631d into main Jul 26, 2026
49 checks passed
@Byron
Byron deleted the more-unsafe-options branch July 26, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants