/

CVE-2026-67322

Severity:

HIGH RISK

(7.5)

Env Variable Exposure (CWE-200) in GitPython clone URLs

CVE-2026-67322

Analyzed

Vulnerability type

Category:

Information Exposure

CWE:

CWE-200

Impact:

Credential and Secret Exfiltration

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

GitPython's Repo.clone_from() leaks environment variables when processing attacker-controlled clone URLs using os.path.expandvars().

If an attacker can influence the remote URL, they can cause secrets such as cloud credentials or access tokens to be substituted into the URL and exfiltrated over the network during the clone operation.

Affected context

This vulnerability appears in applications or automation scripts that use GitPython's Repo.clone_from() with remote URLs that are not fully trusted.

On non-Cygwin platforms, the library applies environment-variable expansion to the URL before invoking git clone, which can inject sensitive values into the outgoing request.

The risk is most pronounced in CI/CD pipelines, deployment tooling, or services that both store secrets in environment variables and accept user-controlled or indirectly influenced repository URLs.

Exploit preconditions

  • Attack surface: Any code path that calls Repo.clone_from() with a URL that can be set or influenced by an external party (e.g., request parameters, job definitions, config files).
  • Required access: Ability to supply or modify the clone URL value, either directly through an API or indirectly through configuration.
  • Trigger point: The call to Git.polish_url() inside Repo.clone_from(), which invokes os.path.expandvars() on the URL on non-Cygwin systems.
  • Why exploitation is possible: Environment-variable expansion is applied to untrusted URLs, so $VAR or ${VAR} segments are replaced with process environment values and then sent over the network as part of the git clone request to an attacker-controlled host.

Why this happens

The underlying flaw is an information exposure pattern where sensitive process state (environment variables) is implicitly mixed into untrusted data.

GitPython's Git.polish_url() method invokes os.path.expandvars() on the caller-supplied URL, causing any $NAME or ${NAME} placeholders to be replaced with environment variable values.

Because this transformation occurs on potentially attacker-controlled input, secrets present in the hosting process environment become part of the outbound URL, aligning with CWE-200: Information Exposure through unintended inclusion of confidential data in externally visible communications.

Potential impact

  • Secrets such as cloud access keys, CI/CD access tokens, or API keys may be disclosed to attacker-controlled servers.
  • Compromise of cloud infrastructure or repositories if leaked credentials are used for unauthorized access.
  • Lateral movement within build or deployment environments using harvested tokens.
  • Long-term supply-chain risk if attackers maintain persistent access via stolen credentials.

General mitigation guidance

Mitigation centers on separating sensitive process state from untrusted URL handling and minimizing what environment data is ever interpolated.

Defensive patterns include:

  • Avoiding environment-variable expansion on any input that may include untrusted or partially trusted data.
  • Treating clone URLs and similar connection strings as opaque values and passing them directly to underlying tools without preprocessing.
  • Constraining where secrets are stored and ensuring high-value credentials are not broadly available in process environments for tools that process user-controlled data.
  • Introducing explicit allowlists or validation for acceptable URL formats before invoking clone operations or other network calls.

How teams detect issues like this

Potential detection approaches include:

  • Static analysis checks for calls to os.path.expandvars(), os.path.expanduser(), or similar APIs on data derived from external inputs such as HTTP parameters, job configs, or user-specified URLs.
  • Code review guidelines that flag any preprocessing of network endpoints with environment expansion or string templating using process secrets.
  • Logging and monitoring of outbound git clone traffic, especially unusual destinations or URLs containing recognizable secret patterns (e.g., keys, tokens).
  • Integration of automated secure coding checks in CI pipelines to enforce policies around environment-variable usage in URL handling code.

Sources

SourceLink
github.comgithub.com/gitpython-developers/GitPython/security/advisories/GHSA-rwj8-pgh3-r573
vulncheck.comvulncheck.com/advisories/gitpython-before-environment-variable-exfiltration-via-clone-from

Frequently asked

questions

Exploitability depends on whether an attacker can influence the clone URL. In systems where users or external services can provide repository URLs, the issue is highly exploitable; in closed systems with only hard-coded URLs, the practical risk is lower.

No direct shell access is required. The attacker only needs a way to cause the vulnerable process to call Repo.clone_from() with a URL they control or can construct, such as via an API endpoint, job configuration, or message queue.

The safest pattern is to remove environment-variable expansion from untrusted URLs entirely and treat clone URLs as plain strings. Any transformation of URLs should be strictly validated and must not include interpolation of process environment values.

Prevention involves adopting a clear policy that secrets and environment variables are never auto-expanded into data derived from external inputs, enforcing this via code review and static analysis, and designing libraries and tooling to be secure-by-default by avoiding convenience features that mix sensitive context into user-controlled data.

Find out what's already
exploitable in your codebase.