Skip to content

Require explicit opt-in for filesystem diffs - #2217

Merged
Byron merged 1 commit into
mainfrom
fix-advisory
Aug 17, 2026
Merged

Require explicit opt-in for filesystem diffs#2217
Byron merged 1 commit into
mainfrom
fix-advisory

Conversation

@Byron

@Byron Byron commented Aug 17, 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.

Advisory

https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-whh4-5q6c-9v3x

GHSA-whh4-5q6c-9v3x reports a repository-boundary bypass in the high-level diff API. This change requires callers to explicitly opt in before diff paths may use filesystem-wide semantics. Reproduction mechanics are intentionally omitted while the advisory is unpublished.

Advisory summary

  • Severity: medium
  • Package: GitPython (pip)
  • Affected range: = 3.1.59
  • Patched versions: none published
  • CVE: none assigned

Changes

  • Classify --no-index as an unsafe diff option.
  • Cover keyword and raw-option spellings through commit and index APIs.
  • Clarify the existing explicit opt-in documentation.

Validation

  • Focused diff security tests: 2 passed.
  • Complete test/test_diff.py: 25 passed, 1 unrelated local-environment failure in staged conflict reporting.
  • Ruff check and format checks passed.
  • git diff --check passed.
  • Git baseline: Git 2.50.1 documents filesystem operand behavior in Documentation/git-diff.adoc and implements it in builtin/diff.c.
  • Post-commit Codex review was attempted once for 14200584 but the CLI usage allowance was exhausted before review began.

Copilot AI lite review requested due to automatic review settings August 17, 2026 04:15

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 hardens GitPython’s high-level diff APIs against repository-boundary bypass by requiring explicit caller opt-in before enabling filesystem-wide diff semantics (--no-index).

Changes:

  • Mark --no-index as an unsafe diff option (requires allow_unsafe_options=True).
  • Add regression tests ensuring both keyword (no_index=True) and raw-option ("--no-index") spellings are rejected by default.
  • Update Diffable.diff documentation to include --no-index in the unsafe-options description.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/test_diff.py Adds tests that --no-index/no_index are blocked unless explicitly allowed.
git/repo/base.py Adds --no-index to the repo’s unsafe diff option allowlist/denylist used by high-level diff APIs.
git/diff.py Updates the allow_unsafe_options docstring to document --no-index as unsafe.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread git/repo/base.py Outdated
Copilot AI review requested due to automatic review settings August 17, 2026 04:34

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

<!-- agent -->
Treat --no-index as an unsafe diff option because it changes path operands
from repository pathspecs to arbitrary filesystem paths. This addresses
GHSA-whh4-5q6c-9v3x without exposing advisory reproduction details.

Assisted-by: GPT 5.6
Co-authored-by: GPT 5.6 <codex@openai.com>
Copilot AI review requested due to automatic review settings August 17, 2026 04:47

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

@Byron
Byron merged commit d160fb4 into main Aug 17, 2026
54 checks passed
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.

2 participants