fix: complete safety checks in Git command wrappers by Byron 路 Pull Request #2251 路 gitpython-developers/GitPython
Repository navigation
fix: complete safety checks in Git command wrappers - #2251
Merged
Byron merged 1 commit into main from arg-bypass Sep 27, 2026
Merged
fix: complete safety checks in Git command wrappers #2251 Byron merged 1 commit into main from arg-bypass
Conversation
Byron commented Sep 26, 2026 · edited Loading
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-6.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Apply the existing safety guards consistently to Git.ls_remote(), Repo.merge_base(), and IndexFile.move(), retaining explicit unsafe opt-ins. merge_base() now propagates command failures except for Git's status 1 result when no common ancestor exists.
The shared protocol check follows Git's transport-selector syntax, preserving ordinary IPv6 URLs and double colons in repository paths. Protocol-like positional arguments and split short-option values require an opt-in; long-form server options remain available. The option checks for merge_base() and move() align their policy with sibling APIs; current Git versions already reject those denylisted options for these two subcommands.
Advisory summary
- Severity: high; CVSS 3.1 score 7.5.
- Package:
GitPythonon PyPI; reported affected range<= 3.1.62. - No patched version or CVE ID is assigned in the advisory.
The advisory is unpublished. Private reproduction and exploit details are omitted.
Validation
Regression cases failed before the fix. On Python 3.14.7 with Git 2.54.0 (Apple Git-157):
- Guard and positional-argument suites: 95 passed.
- Targeted existing guard, protocol, archive, move, and merge-base checks: 133 passed.
- Pre-commit checks passed for all four changed files.
mypy: clean across 46 source files.basedpyright --warnings: no errors or warnings.codex review --commit c480bd5: no actionable findings.
Git behavior was checked against git/git@d38352cd43ab9745686d697872408bc3249a153f, specifically builtin/ls-remote.c, transport.c, builtin/merge-base.c, builtin/mv.c, url.c, and parse-options.c.
Commit: c480bd5 -- fix: complete safety checks in Git command wrappers.
fix: complete safety checks in Git command wrappers
9ad28cc
Mostly a rubber-stamp, particularly the tests I just skimmed. It's also a common fix just with unsafe-options guards, and a regex fix which hopefully is truly better than before. I didn't question it in the interest of time. <!-- agent --> Address GHSA-w8jc-g24h-crhw by applying the existing guard policy to `Git.ls_remote()`, `Repo.merge_base()`, and `IndexFile.move()`. These wrappers previously omitted protocol or option checks already used by sibling APIs. Check flattened positional arguments and split short-option values before `ls_remote()` starts Git, including values that become the repository after option parsing. Add the independent `allow_unsafe_protocols` opt-in and recognize helper selectors even when their address is empty or begins with a newline. Match Git's scheme-character rules at the start of the address so ordinary IPv6 URLs and double colons in repository paths retain their meaning. This addresses the review finding that the broad matcher rejected valid IPv6 remotes. The protocol check is conservative for positional and split option values; long-form `server_option` values remain available without a protocol opt-in. Reuse the revision and pathspec option guards in `merge_base()` and `move()`, with explicit `allow_unsafe_options` opt-ins. Git currently rejects these denylisted options for those subcommands; the checks keep their policy aligned with sibling APIs. Preserve literal move operands behind `--` and validate options before either the dry run or actual move. Only treat exit status 1 from `merge_base()` as no common ancestor. Other failures, including invalid options, now propagate as `GitCommandError` instead of silently returning an empty list. Git reference: `git/git@d38352cd43ab9745686d697872408bc3249a153f`, inspected in `builtin/ls-remote.c`, `transport.c`, `builtin/merge-base.c`, `builtin/mv.c`, `url.c`, and `parse-options.c`. These confirm option parsing before the remote operand, helper selection independently of address contents, long-option abbreviations, and status 1 for unrelated histories. Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <codex@openai.com>Byron force-pushed the arg-bypass branch from
c480bd5 to
9ad28cc
Compare
September 27, 2026 05:43 Byron marked this pull request as ready for review September 27, 2026 05:44 Copilot PR reviewer Copilot
AI
lite review requested due to automatic review settings September 27, 2026 05:44 Copilot started reviewing on behalf of Byron September 27, 2026 05:46
View session
Copilot PR reviewer Copilot
AI
reviewed Sep 27, 2026
View reviewed changes
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 .
Copilot review overview
馃煛 Changes recommended
Unresolved critical release consistency and moderate correctness issues remain.
Review effort: Lite
Findings: 1
This PR adds safety guards to Git command wrappers and improves merge_base() error handling.
Changes:
- Guards
ls_remote(),merge_base(), andIndexFile.move(). - Adds regression tests for unsafe protocols, options, and merge-base failures.
- Documents the security fixes.
| File | Summary | Review notes |
|---|---|---|
test/鈥媡est_command_guards.py |
Adds regression coverage for command guards. | No issues noted. |
git/鈥媟epo/鈥媌ase.py |
Validates merge-base options and propagates failures. | Moderate issue: status 1 is mishandled with is_ancestor. |
git/鈥媔ndex/鈥媌ase.py |
Adds unsafe option validation for moves. | Nit: reference git-mv(1) instead of git-rm(1). |
git/鈥媍md.py |
Adds protocol and option checks to ls_remote(). |
Moderate issue: boolean keyword values can cause a TypeError. |
doc/鈥媠ource/鈥媍hanges.rst |
Documents the security release. | Critical version mismatch; nit: add the required release URL. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
73a72c9
into
main
Sep 27, 2026
51 checks passed
Byron
deleted the
arg-bypass
branch
October 5, 2026 03:23
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment