GHSA-6P8H-3WGX-97GF

GHSA-6P8H-3WGX-97GF is a high-severity OS command injection vulnerability in GitPython (pip), affecting versions <= 3.1.53. It is fixed in 3.1.54.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

GitPython: Incomplete unsafegitclone_options denylist omits --template enabling arbitrary command execution via clone hooks

GitPython's unsafe_git_clone_options denylist omits --template. git clone --template=<dir> copies <dir>/hooks/ into the new repository and runs them (post-checkout fires during clone), so a caller who can influence clone options can achieve arbitrary command execution in the default allow_unsafe_options=False configuration.

Root Cause

base.py:145-152 defines unsafe_git_clone_options = ["--upload-pack","-u","--config","-c"], --template is absent. The guard candidate ['--template'] passes check_unsafe_options (verified). git copies the hook directory and executes post-checkout at checkout time. git's protocol.allow/GIT_ALLOW_PROTOCOL do not gate --template; the incomplete denylist is the only defense.

Proof of Concept

# attacker stages <dir>/hooks/post-checkout (chmod +x)
from git import Repo
Repo.clone_from(src, dst, template='<dir>')   # post-checkout hook executes -> marker created (verified)

Attack Chain

  1. Setup: attacker stages <dir>/hooks/post-checkout (chmod +x). Guard: n/a (filesystem).
  2. Entry: Repo.clone_from(url, path, template='<dir>'). Guard: check_unsafe_options(candidates=['--template'], unsafe=unsafe_git_clone_options). Bypass proof: --template not on the denylist -> passes (verified candidate ['--template'], no error).
  3. Sink: git copies the hook and executes post-checkout at checkout. Impact: ACE, default config (verified marker created).

Bypass Evidence

Live-verified on HEAD (tag 3.1.53): guard candidate ['--template'] passed with no error; staged post-checkout hook executed during clone_from, creating the marker. Independent of the value-smuggle bypass (--template is a legitimate long option that survives any single-char-value fix). Not covered by any existing advisory.

Affected Versions

<= 3.1.53

Impact

Arbitrary OS command execution during clone (default config). Requires an attacker-readable directory containing an executable hook, a genuine second precondition (realistic via shared filesystems, upload dirs, /tmp, or attacker-writable network paths), reflected as AC:H.

Untrusted input reaches a shell command, allowing arbitrary commands to run on the host. Typical impact: code execution in the application's environment.

GHSA-6P8H-3WGX-97GF has a CVSS score of 7.5 (High). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (3.1.54); upgrading removes the vulnerable code path.

Affected versions

GitPython (<= 3.1.53)

Security releases

GitPython → 3.1.54 (pip)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Add --template (and audit for other hook/exec-influencing options) to unsafe_git_clone_options.

Reported by zx (Jace), GitHub: @manus-use

Frequently Asked Questions

  1. What is GHSA-6P8H-3WGX-97GF? GHSA-6P8H-3WGX-97GF is a high-severity OS command injection vulnerability in GitPython (pip), affecting versions <= 3.1.53. It is fixed in 3.1.54. Untrusted input reaches a shell command, allowing arbitrary commands to run on the host.
  2. How severe is GHSA-6P8H-3WGX-97GF? GHSA-6P8H-3WGX-97GF has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of GitPython are affected by GHSA-6P8H-3WGX-97GF? GitPython (pip) versions <= 3.1.53 is affected.
  4. Is there a fix for GHSA-6P8H-3WGX-97GF? Yes. GHSA-6P8H-3WGX-97GF is fixed in 3.1.54. Upgrade to this version or later.
  5. Is GHSA-6P8H-3WGX-97GF exploitable, and should I be worried? Whether GHSA-6P8H-3WGX-97GF is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether GHSA-6P8H-3WGX-97GF is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix GHSA-6P8H-3WGX-97GF? Upgrade GitPython to 3.1.54 or later.

Other vulnerabilities in GitPython

Stop the waste.
Protect your environment with Kodem.