Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

GitPython: Environment-variable exfiltration via os.path.expandvars() on Repo.clone_from() URL

0
High
Published: 07/21/2026 (07/21/2026, 22:06:09 UTC)
Source: GCVE Database
Product: gitpython

Description

GitPython versions up to 3.1.50 (and before 3.1.52) contain a vulnerability where the Repo.clone_from() method passes the remote URL through os.path.expandvars() on non-Cygwin platforms. This causes environment variables embedded as $NAME or ${NAME} in the URL to be expanded using the server process's environment, potentially leaking secrets such as AWS keys or tokens to attacker-controlled hosts. The vulnerability arises because polish_url(), intended for local path normalization, is incorrectly applied to remote URLs without scheme checks or an opt-out for variable expansion. Additionally, the unsafe-protocol check is performed on the raw URL before expansion, allowing bypass if an attacker controls environment variables. No official patch or fix is currently documented.

CVSS v3.1

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Affected software

PyPIghsa
gitpython
Affected versions
<3.1.52

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 07/22/2026, 00:37:14 UTC

Technical Analysis

The vulnerability in GitPython's Repo.clone_from() method stems from the use of os.path.expandvars() on the remote URL argument via Git.polish_url(), which expands environment variables in the URL on non-Cygwin platforms. An attacker controlling the clone URL can embed environment variable tokens (e.g., ${AWS_SECRET_ACCESS_KEY}) that get expanded to secret values from the server's environment before being passed to the git clone subprocess. This results in secrets being transmitted over the network to attacker-controlled hosts, crossing trust boundaries without authentication or user interaction. The unsafe-protocol filter is applied before expansion, enabling protocol bypass if environment variables are also attacker-controlled. The issue affects all GitPython releases up to and including 3.1.50, confirmed on the main branch, with no current official fix or patch available.

Potential Impact

This vulnerability allows an unauthenticated attacker who can supply a clone URL to exfiltrate sensitive environment variables from the server running GitPython. Secrets such as AWS credentials or GitHub tokens can be embedded in the URL and leaked over the network to attacker-controlled domains. This disclosure can lead to compromise of cloud resources or source code repositories. The unsafe-protocol check bypass further increases risk by potentially allowing execution of arbitrary git remote-helper transports if environment variables are also attacker-controlled. The vulnerability does not affect availability or integrity directly but causes high confidentiality impact.

Mitigation Recommendations

Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is released, avoid using Repo.clone_from() with untrusted URLs or URLs that could contain environment variable expansions. Restrict environment variables accessible to the GitPython process to minimize secret exposure. Monitor for updates from the GitPython maintainers addressing this issue. Do not rely on the unsafe-protocol filter alone as it is applied before variable expansion and can be bypassed.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Gcve Source
db.gcve.eu
Osv Id
GHSA-rwj8-pgh3-r573
Osv Schema Version
1.4.0
Aliases
[]
Ecosystems
["PyPI"]
Database Specific Severity
HIGH
Cvss Version
3.1

Threat ID: 6a600a9d9c2644c7f8fdeeba

Added to database: 07/22/2026, 00:11:09 UTC

Last enriched: 07/22/2026, 00:37:14 UTC

Last updated: 07/22/2026, 00:37:14 UTC

Views: 2

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses