<?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>Code-Vulnerability — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/code-vulnerability/</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>Tue, 09 Jan 2024 18:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/code-vulnerability/feed.xml" rel="self" type="application/rss+xml"/><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>