8.8high
gix traversal outside working tree enables arbitrary code execution
- Severity
- 8.8high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 1.23% (higher than 68% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-7w47-3wg8-547cRUSTSEC-2024-0348RUSTSEC-2024-0349RUSTSEC-2024-0350
Description
gitoxide is a pure Rust implementation of Git. During checkout, `gix-worktree-state` 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. This vulnerability leads to a major loss of confidentiality, integrity, and availability, but creating files outside a working tree without attempting to execute code can directly impact integrity as well. This vulnerability has been patched in version(s) 0.36.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Byron gitoxide | < 0.36.0, before 0.36.0 | CVE List |
| gix-worktree-state (crates.io) | before 0.11.0 | GitHub Advisory Database |
| gitoxide (crates.io) | before 0.36.0 | GitHub Advisory Database |
| gix-fs (crates.io) | before 0.11.0, from 0.0.0-0 before 0.11.0 | GitHub Advisory Database, RustSec Advisory Database |
| gix-worktree (crates.io) | before 0.34.0, from 0.0.0-0 before 0.34.0 | GitHub Advisory Database, RustSec Advisory Database |
| gix (crates.io) | before 0.63.0 | GitHub Advisory Database |
| gitoxide-core (crates.io) | before 0.38.0 | GitHub Advisory Database |
| gix-index (crates.io) | before 0.33.0, from 0.0.0-0 before 0.33.0 | GitHub Advisory Database, RustSec Advisory Database |
All scores
| GitHub_M | 8.8high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| GitHub | 8.8high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| RustSec Advisory Database | 8.8high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
Classification
What each source says
CVE List
gitoxide is a pure Rust implementation of Git. During checkout, `gix-worktree-state` 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. This vulnerability leads to a major loss of confidentiality, integrity, and availability, but creating files outside a working tree without attempting to execute code can directly impact integrity as well. This vulnerability has been patched in version(s) 0.36.0.
GitHub Advisory Database
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.
NVD (es)
gitoxide es una implementación Rust pura de Git. Durante el pago, `gix-worktree-state` no verifica que las rutas apunten a ubicaciones en el árbol de trabajo. Un repositorio especialmente manipulado puede, cuando se clona, colocar archivos nuevos en cualquier lugar donde la aplicación pueda escribirlos. Esta vulnerabilidad provoca una pérdida importante de confidencialidad, integridad y disponibilidad, pero la creación de archivos fuera de un árbol de trabajo sin intentar ejecutar código también puede afectar directamente la integridad. Esta vulnerabilidad ha sido parcheada en las versiones 0.36.0.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-35186 changed 2024-08-02 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-7w47-3wg8-547c changed 2026-09-10 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2024-0348 changed 2026-11-09 | CC0-1.0 |
| RustSec Advisory Database | RUSTSEC-2024-0349 changed 2026-11-09 | CC0-1.0 |
| RustSec Advisory Database | RUSTSEC-2024-0350 changed 2026-11-09 | CC0-1.0 |
| NVD | CVE-2024-35186 changed 2026-06-17 | Public domain |