<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>GitPython (&lt;= 3.1.57) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/gitpython--3.1.57/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Fri, 07 Aug 2026 21:31:39 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/gitpython--3.1.57/feed.xml" rel="self" type="application/rss+xml"/><item><title>Path Traversal in GitPython via Malicious Submodule Names</title><link>https://feed.craftedsignal.io/briefs/2026-08-gitpython-traversal/</link><pubDate>Fri, 07 Aug 2026 21:31:39 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-08-gitpython-traversal/</guid><description>GitPython fails to validate submodule names defined in .gitmodules files, allowing attackers to perform path traversal and create arbitrary Git repositories outside the intended working tree during submodule initialization.</description><content:encoded><![CDATA[<p>GitPython is vulnerable to a path traversal flaw (CWE-22) when initializing submodules. The library's <code>sm_name()</code> function, which extracts the name of a submodule from the <code>.gitmodules</code> file, performs no validation on the returned string. When <code>submodule_update(init=True)</code> is called, the library constructs an absolute path for the submodule's separate Git directory by joining the target directory with the unvalidated submodule name.</p>
<p>An attacker can craft a malicious Git repository containing a <code>.gitmodules</code> file with a submodule name consisting of directory traversal sequences (e.g., <code>../../../../path/to/target</code>). When a victim clones this repository and initializes the submodules using GitPython, the library creates a new, fully initialized Git repository at the attacker-specified path. This vulnerability affects GitPython versions up to and including 3.1.57. This vulnerability is significant because it mirrors a class of attacks historically patched in the core Git CLI (CVE-2018-11235), and it poses a high risk to automated systems such as CI/CD pipelines, IDEs, and dependency managers that automatically clone and initialize submodules using GitPython.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker creates a malicious Git repository and modifies the <code>.gitmodules</code> file.</li>
<li>Attacker sets the <code>[submodule &quot;...&quot;]</code> header name to include traversal sequences (e.g., <code>../../../../tmp/malicious_dir</code>).</li>
<li>Attacker hosts the repository on a platform accessible to the victim.</li>
<li>Victim executes a process that uses GitPython to clone the repository (e.g., <code>git.Repo.clone_from()</code>).</li>
<li>The application calls <code>sm.update(init=True)</code> or <code>repo.submodules</code> on the cloned repository.</li>
<li>GitPython parses the malicious <code>.gitmodules</code> name field without validation.</li>
<li>GitPython joins the unsafe name to the base directory path using <code>os.path.join</code>.</li>
<li>GitPython executes a command or file operation to create a new Git repository at the traversal-escaped path.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation allows for the creation of arbitrary directories and Git repositories on the victim's filesystem, limited only by the privileges of the process running GitPython. This can lead to arbitrary file writes, potential overwriting of critical configuration files if the path is carefully chosen, and the introduction of malicious Git hooks or configurations at locations controlled by the attacker. Automated build environments are particularly susceptible due to the high volume of automated submodule initialization.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Update GitPython to a version where submodule name validation is implemented to prevent directory traversal.</li>
<li>Restrict the privileges of service accounts executing GitPython clones, ensuring they operate with minimal filesystem permissions.</li>
<li>Implement pre-processing logic to validate submodule names in <code>.gitmodules</code> files before passing them to GitPython, ensuring they do not contain path traversal characters.</li>
<li>Audit CI/CD configurations to determine if GitPython is used for recursive submodule initialization and move to hardened environments where possible.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>remote-code-execution</category><category>input-validation</category><category>gitpython</category><category>python</category></item><item><title>GitPython Command Injection via Unsafe Git Option Guard Bypass</title><link>https://feed.craftedsignal.io/briefs/2026-08-gitpython-bypass/</link><pubDate>Fri, 07 Aug 2026 21:31:23 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-08-gitpython-bypass/</guid><description>A bypass of the GitPython safety guard allows arbitrary OS command execution via token smuggling when using single-character keyword arguments with split_single_char_options=False.</description><content:encoded><![CDATA[<p>GitPython versions up to and including 3.1.57 contain a command injection vulnerability stemming from an incomplete fix for a previous guard bypass (GHSA-r9mr-m37c-5fr3). The library provides an <code>unsafe_git_clone_options</code> guard to prevent the passage of dangerous flags (e.g., <code>--upload-pack</code>) to the underlying git binary. An attacker who can control keyword arguments passed to GitPython methods (like <code>clone_from</code>, <code>fetch</code>, or <code>push</code>) can bypass this guard by setting <code>split_single_char_options=False</code> and providing a single-character key with a value containing a malicious command.</p>
<p>The guard's candidate inspection logic fails to generate candidates for the joined tokens created when <code>split_single_char_options</code> is disabled. Consequently, the guard inspects the single-character key (e.g., '-n'), finds it safe, and passes. The subsequent <code>transform_kwarg</code> logic then assembles a joined token (e.g., <code>-nutouch &lt;cmd&gt;;git-upload-pack</code>) which the git binary parses as the <code>--upload-pack</code> flag. This results in the execution of the injected command with the privileges of the host process.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker identifies an application endpoint that forwards user-controlled dictionaries as keyword arguments to a GitPython method (e.g., <code>Repo.clone_from(url, path, **kwargs)</code>).</li>
<li>Attacker provides a payload dict: <code>{'split_single_char_options': False, 'n': 'utouch /tmp/ACE;git-upload-pack'}</code>.</li>
<li>GitPython internal <code>_option_candidates</code> function processes the kwargs and identifies only <code>['-n']</code> as a candidate.</li>
<li><code>check_unsafe_options</code> compares <code>['-n']</code> against the safety denylist.</li>
<li>The denylist check passes because <code>['-n']</code> is not considered an unsafe option, failing to see the smuggled command within the value.</li>
<li>The <code>transform_kwarg</code> function merges the key and value into a single CLI token: <code>-nutouch /tmp/ACE;git-upload-pack</code>.</li>
<li>The final argument list is passed to the underlying <code>git</code> subprocess.</li>
<li>Git parses the joined flag as <code>--upload-pack=utouch /tmp/ACE;git-upload-pack</code>, leading to arbitrary command execution.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation allows for arbitrary OS command execution as the user running the GitPython process. This vulnerability affects any application utilizing GitPython's guarded methods while exposing kwargs to user input. The impact is significant as it facilitates unauthorized code execution and potential lateral movement or system compromise within environments hosting Git-integrated automation or CI/CD pipelines.</p>
<h2 id="recommendation">Recommendation</h2>
<p>Prioritize upgrading GitPython to a version where <code>_option_candidates</code> includes value-derived candidates regardless of <code>split_single_char_options</code>. If an immediate patch is unavailable, audit all code paths that forward user-supplied dictionaries as <code>**kwargs</code> to GitPython methods. Implement strict allowlisting for all keyword arguments instead of relying on the library's default guards.</p>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>execution</category><category>library-vulnerability</category><category>command-injection</category><category>remote-code-execution</category><category>injection</category><category>gitpython</category><category>supply-chain</category></item></channel></rss>