GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — guard unsafe git command options by Byron · Pull Request #2163 · gitpython-developers/GitPython

Conversation

@Byron

@Byron Byron commented Jun 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Tasks

  • basic review of the Codex 5.5 based rework of the previous PR. Didn't even look at the copilot comments and their auto-resolution.
  • @EliahKagan 's in-depth review and validation of the advisory

Advisory summary

  • Advisory: GHSA-956x-8gvw-wg5v
  • GHSA: GHSA-956x-8gvw-wg5v
  • Severity: high
  • Affected package: GitPython (pip)
  • Vulnerable range: <= 3.1.50
  • Patched versions: not specified in advisory
  • CVE: not listed
  • Issue pattern: command execution / argument injection via unguarded command options

Validation:

  • Added regression tests for archive, iter_commits, blame, and git ls-remote unsafe option handling.
  • Focused validation not runnable here due missing pytest module in environment.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI review requested due to automatic review settings June 17, 2026 04:32
Copilot AI reviewed Jun 17, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds protections against unsafe git options (notably options that can lead to command execution or arbitrary file writes) by introducing default rejection behavior plus an explicit allow_unsafe_options opt-in, along with regression tests.

Changes:

  • Add unsafe-option checks for archive, rev-based traversal APIs (iter_commits, Commit.iter_items), and blame APIs with allow_unsafe_options overrides.
  • Add a dedicated Git.ls_remote() wrapper that rejects unsafe options by default (opt-in supported).
  • Add regression tests covering unsafe-option rejection and opt-in behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
git/repo/base.py Adds unsafe option lists and default guarding for archive, iter_commits, and blame APIs via allow_unsafe_options.
git/objects/commit.py Adds unsafe revision option guarding to Commit.iter_items plus allow_unsafe_options.
git/cmd.py Adds ls_remote() wrapper and blocks unsafe options by default with opt-in.
test/test_repo.py Adds regression tests ensuring unsafe options are rejected for archive, iter_commits, and blame.
test/test_remote.py Adds regression tests for unsafe ls-remote options rejection and opt-in behavior.
test/test_commit.py Adds regression test ensuring Commit.iter_items rejects unsafe revisions.
Comments suppressed due to low confidence (2)

git/repo/base.py:788

  • For rev-based wrappers, the unsafe-option check only inspects the rev argument string. However, --output/-o are primarily options and can also be supplied via kwargs (and via rev_opts in blame()), which this change currently doesn’t guard. Mandatory: when allow_unsafe_options is false, validate unsafe options across all user-controlled option channels for these commands (e.g., kwargs option keys and rev_opts entries), not just rev.
    def iter_commits(

git/repo/base.py:1208

  • For rev-based wrappers, the unsafe-option check only inspects the rev argument string. However, --output/-o are primarily options and can also be supplied via kwargs (and via rev_opts in blame()), which this change currently doesn’t guard. Mandatory: when allow_unsafe_options is false, validate unsafe options across all user-controlled option channels for these commands (e.g., kwargs option keys and rev_opts entries), not just rev.
    def blame(

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test_repo.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test_repo.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Byron June 17, 2026 04:44
View session
@Byron
Byron force-pushed the fix-unguarded-blame branch from d0a9007 to 0a52e59 Compare June 17, 2026 05:52
Copilot AI review requested due to automatic review settings June 17, 2026 05:55
@Byron
Byron force-pushed the fix-unguarded-blame branch from 0a52e59 to 550d74e Compare June 17, 2026 05:55
Copilot AI reviewed Jun 17, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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 6 out of 6 changed files in this pull request and generated 5 comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/objects/commit.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/test_repo.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron force-pushed the fix-unguarded-blame branch from 550d74e to cf7ea86 Compare June 17, 2026 06:03
Copilot started reviewing on behalf of Byron June 17, 2026 06:06
View session
Copilot AI review requested due to automatic review settings June 17, 2026 06:06
@Byron
Byron force-pushed the fix-unguarded-blame branch from cf7ea86 to 114cd76 Compare June 17, 2026 06:06
Copilot AI reviewed Jun 17, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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 6 out of 6 changed files in this pull request and generated 3 comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

EliahKagan
EliahKagan reviewed Jun 17, 2026
View reviewed changes

@EliahKagan EliahKagan left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Many of the changes here seem good and even necessary, but I'm not sure there's really a way to improve things overall by selectively blocking or redirecting dynamic commands on Git instances. The purpose of Git instances is to pass arguments straightforwardly into git commands via Git.execute. I've posted this comment, which references that previous decision. To be clear, as noted there, I am not confident that I fully understand all aspects of this situation; but just in case I am not totally mistaken, I wanted to raise this concern rather than waiting until after a release that might introduce new potentially unsatisfiable guarantees.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot started reviewing on behalf of Byron June 17, 2026 06:25
View session
@Byron
Byron marked this pull request as draft June 17, 2026 07:17
@Byron

Byron commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

My apologies, this PR isn't supposed to be undrafted, nor is Codex 5.3 spark (too dumb) supposed to write into my checkboxes.

I didn't even take a look at it yet.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@EliahKagan

EliahKagan commented Jun 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Thanks for clarifying. I didn't look at the checkboxes, but the non-draft status was a factor that nudged me to comment here (rather than only in the linked thread).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron marked this pull request as ready for review June 17, 2026 09:17
Copilot AI review requested due to automatic review settings June 17, 2026 09:17
Copilot started reviewing on behalf of Byron June 17, 2026 09:18
View session
@Byron
Byron requested a review from EliahKagan June 17, 2026 09:19
Copilot AI reviewed Jun 17, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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 2 comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/objects/commit.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Byron

Byron commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

This might at least be a partial solution, as it would fix iter_items(). The other commands are probably not exploitable, but I leave this to the second and more thorough review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Byron Byron added the waiting for feedback label Jun 17, 2026
Copilot AI review requested due to automatic review settings July 9, 2026 09:26
Copilot started reviewing on behalf of Byron July 9, 2026 09:28
View session
Copilot AI reviewed Jul 9, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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 9 out of 9 changed files in this pull request and generated 2 comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/cmd.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread git/repo/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI review requested due to automatic review settings July 12, 2026 12:59
@Byron
Byron force-pushed the fix-unguarded-blame branch 2 times, most recently from 5037f36 to 3af2b29 Compare July 12, 2026 13:06
Copilot AI reviewed Jul 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Byron
Byron force-pushed the fix-unguarded-blame branch from 3af2b29 to 9450bf6 Compare July 12, 2026 13:30
@codex @Byron
fix: Guard unsafe git command options (GHSA-956x-8gvw-wg5v)
701ce32
Reject command options that can execute arbitrary helpers or write files when passed through archive, revision traversal, blame, clone, fetch, pull, push, and ls-remote APIs. Validate positional option tokens and transformed keyword options consistently, including Git-supported long-option abbreviations, attached short-option values, and falsey stringifiable remotes. Preserve explicit allow_unsafe_options and allow_unsafe_protocols escape hatches.

Add regression coverage for each guarded API, option spelling and abbreviation forms, inert keyword values, mixed positional and keyword candidates, tuple blame options, stringifiable remotes, and unsafe commands that must not create marker files.

Reviewed-by: Sebastian Thiel <[email protected]>
@Byron
Byron force-pushed the fix-unguarded-blame branch from 9450bf6 to 701ce32 Compare July 12, 2026 13:30
@Byron Byron removed the waiting for feedback label Jul 12, 2026
@Byron

Byron commented Jul 12, 2026

Copy link
Copy Markdown
Member Author

Let's opt for a post-release fix as needed rather than holding this up for much longer.

Once again, I ran the tests locally and rely on the few jobs that pass, knowing the other ones won't be picked up due to runner shortage or GH issues.

Lastly, I have used GPT 5.6 on all of this, and let its review (high thinking) found yet another issue that is fixed here.
This doesn't mean it's perfect, but it's probably better than anything before it.

Lastly, I only performed a review, no refackiew, so admittedly this is mostly agent work and I probably wouldn't see issues.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron merged commit af027be into main Jul 12, 2026
23 of 29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@it-integrations it-integrations mentioned this pull request Aug 6, 2026
🟠 [High] GitPython: Command Injection via Unguarded Git Options in Repo.archive(), git.ls_remote(), and Arbitrary File Overwrite via Repo.iter_commits() / Repo.blame() Latch/connectedhomeip#42
Open
736-c41-2c1-e464fc974 pushed a commit to Swiss-Armed-Forces/Loom that referenced this pull request Aug 16, 2026
open-source Pipeline Loom MR Pipeline Trigger @736-c41-2c1-e464fc974
chore(deps): update dependency gitpython to v3.1.52
c1b7b14
This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [gitpython](https://github.com/gitpython-developers/GitPython) | dev | patch | `3.1.50` → `3.1.52` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/gitpython-developers/GitPython/badge)](https://securityscorecards.dev/viewer/?uri=github.com/gitpython-developers/GitPython) |

---

### Release Notes

<details>
<summary>gitpython-developers/GitPython (gitpython)</summary>

### [`v3.1.52`](https://github.com/gitpython-developers/GitPython/releases/tag/3.1.52): Security

[Compare Source](gitpython-developers/GitPython@3.1.51...3.1.52)

<GHSA-rwj8-pgh3-r573>: Environment-variable exfiltration via os.path.expandvars() on Repo.clone\_from() URL

#### What's Changed

- Skip cross-drive relative config test on Windows by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2171](gitpython-developers/GitPython#2171)
- fix: preserve literal clone URLs by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2172](gitpython-developers/GitPython#2172)

**Full Changelog**: <gitpython-developers/GitPython@3.1.51...3.1.52>

### [`v3.1.51`](https://github.com/gitpython-developers/GitPython/releases/tag/3.1.51): - Security

[Compare Source](gitpython-developers/GitPython@3.1.50...3.1.51)

#### What's Changed

- Add AI-disclosure and quality requirements to the contribution guidelines by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2143](gitpython-developers/GitPython#2143)
- docs(cmd): clarify Git.execute() string vs list command argument by [@&#8203;mvanhorn](https://github.com/mvanhorn) in [#&#8203;2144](gitpython-developers/GitPython#2144)
- Rewrite Git.execute() command parameter docstring per [#&#8203;2146](gitpython-developers/GitPython#2146) by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2147](gitpython-developers/GitPython#2147)
- Document init script behavior with multiple master remotes by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2148](gitpython-developers/GitPython#2148)
- Bump git/ext/gitdb from `335c0f6` to `0a019a2` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2149](gitpython-developers/GitPython#2149)
- Support relative worktree paths (git 2.48+ worktree.useRelativePaths) by [@&#8203;elovelan](https://github.com/elovelan) in [#&#8203;2151](gitpython-developers/GitPython#2151)
- Defer xfail condition evaluation with xfail\_if\_raises context manager by [@&#8203;elovelan](https://github.com/elovelan) in [#&#8203;2153](gitpython-developers/GitPython#2153)
- Run more submodule tests on Cygwin (fix flaky xfails) by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2154](gitpython-developers/GitPython#2154)
- Cut xtrace noise from POSIX-ownership diagnostic steps by [@&#8203;EliahKagan](https://github.com/EliahKagan) in [#&#8203;2156](gitpython-developers/GitPython#2156)
- Support index diffs against the empty tree by [@&#8203;puneetdixit200](https://github.com/puneetdixit200) in [#&#8203;2155](gitpython-developers/GitPython#2155)
- refactor: seperate out Progress type by [@&#8203;LoeschMaximilian](https://github.com/LoeschMaximilian) in [#&#8203;2157](gitpython-developers/GitPython#2157)
- Bump <https://github.com/astral-sh/ruff-pre-commit> from v0.15.12 to 0.15.15 in the pre-commit group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2160](gitpython-developers/GitPython#2160)
- Bump actions/checkout from 6 to 7 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2164](gitpython-developers/GitPython#2164)
- Bump git/ext/gitdb from `0a019a2` to `4950ea9` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2165](gitpython-developers/GitPython#2165)
- Bump <https://github.com/astral-sh/ruff-pre-commit> from v0.15.15 to 0.15.20 in the pre-commit group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2166](gitpython-developers/GitPython#2166)
- Add Commit.is\_shallow property; document stats() limitation at shallow boundary by [@&#8203;harshitayadavv](https://github.com/harshitayadavv) in [#&#8203;2167](gitpython-developers/GitPython#2167)
- Allow relative config paths with includes by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2169](gitpython-developers/GitPython#2169)
- Reject abbreviated forms of unsafe git options by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2168](gitpython-developers/GitPython#2168)
- guard unsafe git command options by [@&#8203;Byron](https://github.com/Byron) in [#&#8203;2163](gitpython-developers/GitPython#2163)

#### New Contributors

- [@&#8203;elovelan](https://github.com/elovelan) made their first contribution in [#&#8203;2151](gitpython-developers/GitPython#2151)
- [@&#8203;puneetdixit200](https://github.com/puneetdixit200) made their first contribution in [#&#8203;2155](gitpython-developers/GitPython#2155)
- [@&#8203;LoeschMaximilian](https://github.com/LoeschMaximilian) made their first contribution in [#&#8203;2157](gitpython-developers/GitPython#2157)
- [@&#8203;harshitayadavv](https://github.com/harshitayadavv) made their first contribution in [#&#8203;2167](gitpython-developers/GitPython#2167)

**Full Changelog**: <gitpython-developers/GitPython@3.1.50...3.1.51>

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNzAuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI3MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

See merge request swiss-armed-forces/cyber-command/cea/loom!679

Co-authored-by: Loom MR Pipeline Trigger <group_103951964_bot_9504bb8dead6d4e406ad817a607f24be@noreply.gitlab.com>
@Byron
Byron deleted the fix-unguarded-blame branch October 5, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@EliahKagan EliahKagan Awaiting requested review from EliahKagan

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Byron @EliahKagan @codex
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.