<?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>Gix — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/gix/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Mon, 29 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/gix/feed.xml" rel="self" type="application/rss+xml"/><item><title>gix and gitoxide Submodule Path Traversal Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-29-git-submodule-path-traversal/</link><pubDate>Mon, 29 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-29-git-submodule-path-traversal/</guid><description>A path traversal vulnerability exists in gix and gitoxide where unvalidated submodule names from `.gitmodules` can be used to escape the `.git/modules` directory, potentially leading to repository confusion by redirecting submodule state inspection and open operations to attacker-controlled paths.</description><content:encoded><![CDATA[<p>A path traversal vulnerability has been identified in the gix and gitoxide libraries. The vulnerability stems from the lack of validation of submodule names extracted from the <code>.gitmodules</code> file. Specifically, these submodule names are used to construct file paths for accessing submodule Git directories. An attacker can craft a malicious <code>.gitmodules</code> file containing a submodule name with path traversal sequences (e.g., <code>../../../escaped-target.git</code>). This allows the attacker to redirect <code>state()</code> and <code>open()</code> calls to an arbitrary repository outside the intended <code>.git/modules</code> directory. This can cause a vulnerable application using these libraries to operate on an unexpected repository, leading to potential security issues. The vulnerability affects gix versions prior to 0.83.0 and gitoxide versions up to and including 0.52.0.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker crafts a malicious <code>.gitmodules</code> file.</li>
<li>The malicious <code>.gitmodules</code> file contains a submodule name with path traversal sequences (e.g., <code>../../../escaped-target.git</code>).</li>
<li>A vulnerable application using gix or gitoxide parses the malicious <code>.gitmodules</code> file.</li>
<li>The application extracts the unvalidated submodule name from the <code>.gitmodules</code> file.</li>
<li>The application constructs a file path to the submodule&rsquo;s Git directory using the unvalidated name: <code>&lt;superproject common_dir&gt;/modules/&lt;submodule name&gt;</code>.</li>
<li>Due to the path traversal sequences in the submodule name, the constructed path escapes the intended <code>.git/modules</code> directory.</li>
<li>The application calls <code>state()</code> or <code>open()</code> using the escaped path, which leads to an attacker-controlled repository.</li>
<li>The application performs operations (enumeration, inspection, etc.) on the attacker-chosen repository, potentially leading to information disclosure or other unexpected behavior.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>The vulnerability can lead to repository confusion, where a vulnerable application operates on an unintended repository. While the report does not claim direct command execution, the redirection of repository access can have significant consequences. For example, if the application relies on submodule state for access control or other security-sensitive operations, an attacker could potentially bypass these checks by redirecting the application to a controlled repository. The number of victims and sectors affected depend on the adoption of the vulnerable gix and gitoxide libraries.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to gix version 0.83.0 or later to patch the vulnerability.</li>
<li>Upgrade to a version of gitoxide later than 0.52.0, if available (or switch to gix).</li>
<li>Deploy the Sigma rule <code>Detect Git Submodule Path Traversal in Configuration</code> to identify potentially malicious <code>.gitmodules</code> files based on submodule name patterns.</li>
<li>Sanitize or validate submodule names before using them to construct file paths, as recommended in the advisory.</li>
<li>Monitor application logs for suspicious activity related to submodule operations, especially those involving unusual file paths.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>path-traversal</category><category>git</category><category>repository-confusion</category><category>supply-chain</category></item><item><title>gitoxide Arbitrary Command Execution via .gitmodules Bypass</title><link>https://feed.craftedsignal.io/briefs/2024-01-09-gitoxide-rce/</link><pubDate>Tue, 09 Jan 2024 18:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-09-gitoxide-rce/</guid><description>A vulnerability in gitoxide's `gix_submodule::File::update()` allows arbitrary command execution via a crafted `.gitmodules` file by incorrectly validating the source of the `update` command, enabling an attacker to inject malicious commands after a submodule has been initialized.</description><content:encoded><![CDATA[<p>A vulnerability exists in gitoxide&rsquo;s <code>gix_submodule::File::update()</code> function, specifically in versions 0.31.0 to 0.82.0, that allows for arbitrary command execution. The vulnerability arises from an insufficient check on the origin of the <code>update</code> command specified in a <code>.gitmodules</code> file.  An attacker can exploit this by pushing a new commit with a malicious <code>update</code> command in <code>.gitmodules</code> after the victim initializes the submodule.  This bypasses the intended security guard, leading to potential remote command execution in downstream code that relies on <code>Submodule::update()</code> and trusts the safety of <code>Update::Command(_)</code>. This issue is similar to CVE-2019-19604, highlighting the risk of unchecked commands in submodule configurations.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker creates a repository with a benign <code>.gitmodules</code> file, containing no <code>update</code> key.</li>
<li>A victim clones the attacker&rsquo;s repository and runs <code>git submodule init</code>, which populates the <code>.git/config</code> file with submodule information (URL, active status), but not the <code>update</code> key.</li>
<li>The attacker pushes a new commit to the repository, adding a malicious <code>update = !&lt;command&gt;</code> line to the <code>.gitmodules</code> file (e.g., <code>update = !touch /tmp/pwned</code>).</li>
<li>The victim runs <code>git pull</code> to update their local repository, incorporating the attacker&rsquo;s modified <code>.gitmodules</code> file. The <code>.git/config</code> file remains unchanged.</li>
<li>A gitoxide-based application calls <code>Submodule::update()</code> to determine the submodule update strategy.</li>
<li>The vulnerable <code>gix_submodule::File::update</code> function is called, which incorrectly validates the source of the <code>update</code> command.</li>
<li>The function checks that a submodule section with the same name exists in a non-.gitmodules source, but does not verify if the update value comes from that section, bypassing the intended security guard.</li>
<li>The attacker-controlled shell command from the <code>.gitmodules</code> file is executed, leading to arbitrary command execution.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>The vulnerability allows an attacker to execute arbitrary commands on a system running gitoxide-based applications that utilize submodules. This could lead to complete system compromise, data exfiltration, or denial of service. Any tool, IDE plugin, or CI integration building submodule-update functionality on top of <code>gix</code> within the affected version range inherits this vulnerability.  Successful exploitation depends on the vulnerable application&rsquo;s trust in the output of <code>Submodule::update()</code> which determines the update strategy.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to <code>gix</code> version 0.83.0 or later to patch the vulnerability (<a href="https://github.com/advisories/GHSA-f26g-jm89-4g65)">https://github.com/advisories/GHSA-f26g-jm89-4g65)</a>.</li>
<li>Implement additional validation and sanitization of submodule configurations, especially when handling <code>Update::Command(_)</code> from <code>Submodule::update()</code>, to prevent unintended command execution.</li>
<li>Deploy the Sigma rule below to detect potential exploitation attempts by monitoring for the execution of unexpected commands based on submodule configuration.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>code-vulnerability</category><category>remote-code-execution</category><category>gitoxide</category></item></channel></rss>