gix Submodule Path Traversal and Credential Disclosure
A vulnerability in gix's submodule name validation allows path traversal via a crafted .gitmodules file, combined with a trust inheritance flaw in Submodule::open(), enabling arbitrary git repository config reading, including credentials, with full trust.
A path traversal vulnerability exists within the gix library, specifically affecting applications that utilize git submodules. This flaw stems from inadequate validation of submodule names, allowing an attacker to craft a malicious .gitmodules file containing directory traversal sequences (e.g., ../). The vulnerability is amplified by a trust inheritance issue where submodule repositories inherit the git_dir_trust setting from their parent, bypassing ownership checks. Successful exploitation allows an attacker to read sensitive configuration files, potentially including credentials, from arbitrary git directories. This vulnerability affects gix versions prior to 0.83.0 and gix-validate versions 0.10.0 and earlier.
Attack Chain
- An attacker crafts a malicious git repository with a specially crafted
.gitmodulesfile containing path traversal sequences in the submodule name (e.g.,x..y/../../..). - A victim clones the attacker’s repository using a tool built on the vulnerable gitoxide library (gix).
- The victim’s tool iterates through the submodules, potentially triggered by commands like
submodule.open()orsubmodule.status(). - The
git_dir()function, due to insufficient validation, constructs a path that traverses outside the intended submodule directory (e.g., resolving to the parent.git/directory). - The
open_opts()function is called withTrust::Fullinherited from the parent repository, skipping ownership checks. - The library opens the traversed path (e.g., the parent’s
.git/configfile) as a trusted repository. - The attacker can then access sensitive configuration values, such as
remote.origin.url,http.extraHeader(containing tokens),credential.*sections, andcore.sshCommand. - The attacker extracts the exposed credentials via standard API calls, such as
repo.config_snapshot().string("http.extraHeader").
Impact
Successful exploitation of this vulnerability enables an attacker to read sensitive configuration files from arbitrary git repositories accessible to the vulnerable application. This includes potential disclosure of credentials such as tokens embedded in URLs or HTTP headers, SSH keys, and other sensitive information. The impact is high due to the potential for lateral movement and further compromise within the victim’s environment. This is similar to GHSA-7w47-3wg8-547c.
Recommendation
- Apply the suggested fix by patching the gix and gix-validate libraries to version 0.83.0 or later to resolve the validation bypass and trust inheritance issues.
- Implement a detection rule for process creation events where a git command is executed with a submodule path containing directory traversal sequences (
..) based on the flawed validation ingix-validate/src/submodule.rsas described in the overview. - Deploy the Sigma rule “Detect Git Submodule Path Traversal” to identify potential exploitation attempts (see rules section below).
Detection coverage 2
Detect Git Submodule Path Traversal
highDetects command line arguments indicative of path traversal attempts within git submodule operations.
Suspicious gix process with Trust::Full
mediumDetects processes using the gix library that might inherit Trust::Full, indicating a potential trust bypass vulnerability.
Detection queries are kept inside the platform. Get full rules →