CVE-2024-35186: Gitoxide Gix Traversal Outside Working Tree Vulnerability
HIGHCVE-2024-35186 is a HIGH (CVSS 8.8) gix traversal outside working tree vulnerability (CWE-23: Relative Path Traversal) affecting Gitoxide libraries in the crates.io ecosystem. The issue involves gix traversal outside working tree enables arbitrary code execution. Remediation is available by upgrading affected packages to version 0.36.0, 0.11.0, 0.34.0, 0.63.0, 0.38.0, 0.33.0.
CVE-2024-35186 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-35186
To remediate this vulnerability, upgrade all affected Gitoxide dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade gitoxide to 0.36.0
Upgrade gix-worktree-state to 0.11.0
Upgrade gix-fs to 0.11.0
Upgrade gix-worktree to 0.34.0
Upgrade gix to 0.63.0
Upgrade gitoxide-core to 0.38.0
Upgrade gix-index to 0.33.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for gitoxide
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-35186, inspect your project dependencies for Gitoxide:
inspect dependencies for gitoxide
Analyze the terminal output to locate any version of Gitoxide in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.36.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-23: Relative Path Traversal, where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory. In Gitoxide, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-35186 Affected Gitoxide Versions
7 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
gitoxide
|
crates.io |
< 0.36.0
|
0.36.0
|
|
gix-worktree-state
|
crates.io |
< 0.11.0
|
0.11.0
|
|
gix-fs
|
crates.io |
< 0.11.0
|
0.11.0
|
|
gix-worktree
|
crates.io |
< 0.34.0
|
0.34.0
|
|
gix
|
crates.io |
< 0.63.0
|
0.63.0
|
|
gitoxide-core
|
crates.io |
< 0.38.0
|
0.38.0
|
|
gix-index
|
crates.io |
< 0.33.0
|
0.33.0
|
References
Frequently Asked Questions
What is CVE-2024-35186?
Which Gitoxide versions are affected?
What version fixes CVE-2024-35186?
Is gitoxide affected?
Is gix-worktree-state affected?
What is the CVSS score of CVE-2024-35186?
What CWE is associated with CVE-2024-35186?
How can I check crates.io dependencies for CVE-2024-35186?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7w47-3wg8-547c",
"modified" : "2024-07-08T16:20:56Z",
"published" : "2024-05-22T14:05:58Z",
"aliases" : [ "CVE-2024-35186" ],
"summary" : "gix traversal outside working tree enables arbitrary code execution",
"details" : "### Summary\n\nDuring 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.\n\n### Details\n\nAlthough `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:\n\n- 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.\n- A tree named `.git` to enter a `.git` directory. This facilitates arbitrary code execution because hooks can be installed.\n\nA 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:\n\n- 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 `../outside` or `.git/hooks/pre-commit`. This is distinct from the more intuitive case a repository containing trees that represent those paths.\n- 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](https://github.com/git/git/security/advisories/GHSA-xjx4-8694-q2fq).\n- On a case-insensitive filesystem (such as NTFS, APFS, or HFS+), a tree named as a case variant of `.git`.\n- On HFS+, a tree named like `.git` or a case variant, with characters added that HFS+ ignores [in collation](https://developer.apple.com/library/archive/technotes/tn/tn1150.html#StringComparisonAlgorithm). See https://github.com/git/git/commit/6162a1d323d24fd8cbbb1a6145a91fb849b2568f.\n- On NTFS, a tree equivalent to `.git` (or a case variant) by the use of [NTFS stream](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c54dec26-1551-4d3a-a0ea-4fa40f848eb3) notation, such as `.git::$INDEX_ALLOCATION`. See [GHSA-5wph-8frv-58vj](https://github.com/git/git/security/advisories/GHSA-5wph-8frv-58vj).\n- On an NTFS volume with [8.3 aliasing](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#short-vs-long-names) enabled, a tree named as `git~1` (or a case variant). See [GHSA-589j-mmg9-733v](https://github.com/git/git/security/advisories/GHSA-589j-mmg9-733v).\n\nWhen a checkout creates some files outside the repository directory but fails to complete, the repository directory is usually removed, but the outside files remain.\n\n### PoC\n\nFor 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.\n\n#### Example: Downward traversal to install hooks\n\n1. Create a new repository with `git init dangerous-repo-installs-hook` and `cd` into the directory.\n2. Create the stand-in called `.git@hooks@pre-commit`, with the *contents*:\n ```sh\n #!/bin/sh\n printf 'Vulnerable!\\n'\n date >vulnerable\n ```\n3. Stage the stand-in: `git add --chmod=+x .git@hooks@pre-commit`\n4. Edit the index: `env LC_ALL=C sed -i.orig 's|\\.git@hooks@pre-commit|.git/hooks/pre-commit|' .git/index`\n5. Commit: `git commit -m 'Initial commit'`\n6. *Optionally*, push to a private remote.\n\nThen, on another or the same machine:\n\n1. Clone the repository with a `gix clone …` command.\n2. Enter the newly created directory.\n3. *Optionally* run `ls -l .git/hooks` to observe that the `pre-commit` hook is already present.\n4. Make a new file and commit it with `git`. This causes the payload surreptitiously installed as a `pre-commit` hook to run, printing the message `Vulnerable!` and creating a file in the current directory containing the current date and time.\n\nNote 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.\n\n#### Example: Upward traversal to create a file above the working tree\n\n1. Create a new repository with `git init dangerous-repo-reaches-up`, and `cd` into the directory.\n2. Create the stand-in: `echo 'A file outside the working tree, somehow.' >..@outside`\n3. Stage the stand-in: `git add ..@outside`\n4. Edit the index: `env LC_ALL=C sed -i.orig 's|\\.\\.@outside|../outside|' .git/index`\n5. Commit: `git commit -m 'Initial commit'`\n6. *Optionally*, push to a private remote.\n\nThen, 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.\n\n### Impact\n\nAny 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.\n\nIn 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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "gix-worktree-state"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.11.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "gitoxide"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.36.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "gix-fs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.11.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "gix-worktree"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.34.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "gix"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.63.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "gitoxide-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.38.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "gix-index"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.33.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Byron/gitoxide/security/advisories/GHSA-7w47-3wg8-547c"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35186"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Byron/gitoxide"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2024-0348.html"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2024-0350.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22", "CWE-23" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-05-22T14:05:58Z",
"nvd_published_at" : "2024-05-23T09:15:09Z"
}
}