CVE-2024–32002 POC
Git versions before certain patched releases mishandled symbolic links in submodules, allowing a malicious repository to write files into the .git directory. An attacker could create a hook that executes during a recursive clone, leading to remote code execution.
medium.com
Published on medium.com
CVE-2024–32002 is a critical vulnerability identified in Git, a widely used version control system. This flaw allows attackers to execute arbitrary code during the cloning of malicious repositories with submodules, potentially leading to remote code execution (RCE).
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a path validation flaw where Git followed a symbolic link in a submodule and wrote files into the parent repository's .git directory instead of the submodule's worktree.
Impact
An attacker could execute arbitrary code on the victim's machine during a recursive clone, potentially leading to a reverse shell.
What the attacker needed
Victim clones a malicious repository recursively; victim uses an affected Git version; attacker can host repositories
The fix
The vulnerability was fixed in Git versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4; users should upgrade.
How it was found
- Configure Git to allow file protocol and symbolic links.
- Create two empty repositories (repo1 and repo2).
- Clone repo1 and create a post-checkout hook containing malicious code.
- Add and push the hook to repo1.
- Clone repo2 and add repo1 as a submodule.
- Create a symbolic link pointing to .git and push the changes.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Git is a tool for tracking changes in code. When you clone a repository that contains submodules (smaller repositories inside it), Git normally keeps files separate. This bug let a malicious repository trick Git into placing a file inside Git's own hidden settings folder, where it could run a script automatically when you clone. That script could then take over your computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.