CVE-2024-35186 — Vulnerability in gix — CVE Details
gix traversal outside working tree enables arbitrary code execution
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.23%). Schedule for your next planned update.
Does your project use an affected gix version?
Paste your Cargo.lock to check it for CVE-2024-35186 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
During checkout, gitoxide does not verify that paths point to locations in the working tree. A specially crafted repository can, when cloned, place new files anywhere writable by the application.
Details
Although gix-worktree-state checks for collisions with existing files, it does not itself check if a path is really in the working tree when performing a checkout, nor do the path checks in gix-fs and gix-worktree prevent this. Cloning an untrusted repository containing specially crafted tree or blob names will create new files outside the repository, or inside the repository or a submodule's .git directory. The simplest cases are:
- A tree named
..to traverse upward. This facilitates arbitrary code execution because files can be placed in one or more locations where they are likely to be executed soon. - A tree named
.gitto enter a.gitdirectory. This facilitates arbitrary code execution because hooks can be installed.
A number of alternatives that achieve the same effect are also possible, some of which correspond to specific vulnerabilities that have affected Git in the past:
- A tree or blob whose name contains one or more
/, to traverse upward or downward. For example, even without containing any tree named..or.git, a repository can represent a file named../outsideor.git/hooks/pre-commit. This is distinct from the more intuitive case a repository containing trees that represent those paths. - In Windows, a tree or blob whose name contains one or more
\, to traverse upward or downward. (Unlike/, these are valid on other systems.) See GHSA-xjx4-8694-q2fq. - On a case-insensitive filesystem (such as NTFS, APFS, or HFS+), a tree named as a case variant of
.git. - On HFS+, a tree named like
.gitor a case variant, with characters added that HFS+ ignores in collation. See https://github.com/git/git/commit/6162a1d323d24fd8cbbb1a6145a91fb849b2568f. - On NTFS, a tree equivalent to
.git(or a case variant) by the use of NTFS stream notation, such as.git::$INDEX_ALLOCATION. See GHSA-5wph-8frv-58vj. - On an NTFS volume with 8.3 aliasing enabled, a tree named as
git~1(or a case variant). See GHSA-589j-mmg9-733v.
When a checkout creates some files outside the repository directory but fails to complete, the repository directory is usually removed, but the outside files remain.
PoC
For simplicity, these examples stage a stand-in file with a valid name, modify the index, and commit. The instructions assume sed supports -i, which is the case on most systems. If using Windows, a Git Bash shell should be used.
Example: Downward traversal to install hooks
- Create a new repository with
git init dangerous-repo-installs-hookandcdinto the directory. - Create the stand-in called
.git@hooks@pre-commit, with the contents:#!/bin/sh printf 'Vulnerable!\n' date >vulnerable - Stage the stand-in:
git add --chmod=+x .git@hooks@pre-commit - Edit the index:
env LC_ALL=C sed -i.orig 's|\.git@hooks@pre-commit|.git/hooks/pre-commit|' .git/index - Commit:
git commit -m 'Initial commit' - Optionally, push to a private remote.
Then, on another or the same machine:
- Clone the repository with a
gix clone …command. - Enter the newly created directory.
- Optionally run
ls -l .git/hooksto observe that thepre-commithook is already present. - Make a new file and commit it with
git. This causes the payload surreptitiously installed as apre-commithook to run, printing the messageVulnerable!and creating a file in the current directory containing the current date and time.
Note that the effect is not limited to modifying the current directory. The payload could be written to perform any action that the user who runs git commit is capable of.
Example: Upward traversal to create a file above the working tree
- Create a new repository with
git init dangerous-repo-reaches-up, andcdinto the directory. - Create the stand-in:
echo 'A file outside the working tree, somehow.' >..@outside - Stage the stand-in:
git add ..@outside - Edit the index:
env LC_ALL=C sed -i.orig 's|\.\.@outside|../outside|' .git/index - Commit:
git commit -m 'Initial commit' - Optionally, push to a private remote.
Then, as above, on the same or another machine, clone the repository with a gix clone … command. Observe that a file named outside is present alongside (not inside) the cloned directory.
Impact
Any use of gix or another application that makes use of gix-worktree-state, or otherwise relies on gix-fs and gix-worktree for validation, is affected, if used to clone untrusted repositories. The above description focuses on code execution, as that leads to a complete loss of confidentiality, integrity, and availability, but creating files outside a working tree without attempting to execute code can directly impact integrity as well.
In use cases where no untrusted repository is ever cloned, this vulnerability has no impact. Furthermore, the impact of this vulnerability may be lower when gix is used to clone a repository for CI/CD purposes, even if untrusted, since in such uses the environment is usually isolated and arbitrary code is usually run deliberately from the repository with necessary safeguards in place.
Advisory Timeline
- First published May 22, 2024 (918 days ago).
- Last revised September 10, 2026 — 841 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
cargo update -p gix --precise 0.63.0
cargo update -p gix-worktree --precise 0.34.0
cargo update -p gix-fs --precise 0.11.0
cargo update -p gix-index --precise 0.33.0
cargo update -p gix-worktree-state --precise 0.11.0
cargo update -p gitoxide-core --precise 0.38.0
cargo update -p gitoxide --precise 0.36.0
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (7)
Affects 1 ecosystem: crates.io (7).
| Package | Fixed In |
|---|---|
| gix crates.io · Affected: All versions | 0.63.0 |
| gix-worktree crates.io · Affected: All versions | 0.34.0 |
| gix-fs crates.io · Affected: All versions | 0.11.0 |
| gix-index crates.io · Affected: All versions | 0.33.0 |
| gix-worktree-state crates.io · Affected: All versions | 0.11.0 |
| gitoxide-core crates.io · Affected: All versions | 0.38.0 |
| gitoxide crates.io · Affected: All versions | 0.36.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-22Path TraversalMITRE
- CWE-23
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 8.8 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
References
Frequently Asked Questions
- What is CVE-2024-35186?
- gix traversal outside working tree enables arbitrary code execution. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.8/10).
- How do I check if my project is affected by CVE-2024-35186?
- CVE-2024-35186 affects gix, gix-worktree and gix-fs (and 4 more). It has a 1.2% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2024-35186 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is an above-median EPSS score — 68.9% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2026-40034HIGH
gitoxide: CommandForbiddenInModulesConfiguration Bypass in gix_submodule::File::update() Enables Arbitrary Command Execution via .gitmodules
- CVE-2026-44471HIGH
gix-fs: Symlink prefix-reuse allows worktree escape during checkout
- CVE-2026-82251HIGH
gix and gitoxide: unvalidated submodule name traverses out of .git/modules and redirects state() / open() to another repository
- CVE-2026-82253HIGH
gix's submodule name validation bypass + trust inheritance flaw enables path traversal and credential disclosure
- CVE-2026-82252HIGH
gix and gitoxide's symlinked .gitmodules are followed and parsed from outside of the repository
- CVE-2025-31130MEDIUM
gitoxide does not detect SHA-1 collision attacks
- CVE-2024-35197MEDIUM
gix refs and paths with reserved Windows device names access the devices
- CVE-2024-32884MEDIUM
gix-transport indirect code execution via malicious username