Skip to content

fix: preserve literal clone URLs#2172

Draft
Byron wants to merge 1 commit into
mainfrom
fix-clone-expandvars
Draft

fix: preserve literal clone URLs#2172
Byron wants to merge 1 commit into
mainfrom
fix-clone-expandvars

Conversation

@Byron

@Byron Byron commented Jul 15, 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

Preserve caller-provided clone URLs literally when invoking Git and when storing the resulting origin URL. Validate unsafe protocols against the exact normalized value passed to Git. Legacy expansion remains available to callers that intentionally normalize local paths.

Security advisory

Advisory summary

  • Severity: High
  • Package: gitpython (pip)
  • Affected range: <= 3.1.50
  • Patched version: not yet assigned
  • CVE: not yet assigned

The advisory remains a draft, so this description intentionally omits exploit details.

Validation

  • pytest test/test_clone.py -q — 20 passed, 1 skipped
  • ruff check on changed files — passed
  • ruff format --check on changed files — passed
  • Full pytest -q — 681 passed, 73 skipped, 1 xfailed; 7 unrelated local environment/baseline failures (including tests that assume a master default branch and local daemon/config behavior)

Git behavior reference

Git passes clone URL arguments through literally; t/t5601-clone.sh exercises accepted clone URL forms without shell-style environment expansion.

@Byron Byron force-pushed the fix-clone-expandvars branch from 2e0a04b to 4db3773 Compare July 15, 2026 14:55
Repo.clone_from() expanded environment-variable references in caller-supplied URLs before passing them to git clone. This could expose process environment values to an untrusted remote and made protocol validation apply to a different value than Git received.

Polish clone URLs without variable or home expansion on native and Cygwin Git, then apply unsafe-protocol validation to that exact normalized value. Preserve the literal URL when normalizing the stored origin after a successful clone, while retaining the existing Git.polish_url() default for callers that intentionally normalize local paths. Add regression coverage for POSIX and Windows variable syntax, Cygwin conversion, stored origins, and post-normalization protocol validation.

Git baseline: git clone passes URL arguments through literally; t/t5601-clone.sh covers the accepted URL forms without shell-style environment expansion.

Security: GHSA-rwj8-pgh3-r573.

Validation:
- pytest test/test_clone.py -q (21 passed, 1 skipped)
- pytest test/test_util.py -q
- ruff check on changed files
- ruff format --check on changed files
- full pytest suite (681 passed, 73 skipped, 1 xfailed; 7 unrelated environment/baseline failures)
@Byron Byron force-pushed the fix-clone-expandvars branch from 4db3773 to 6575026 Compare July 15, 2026 15:03
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