Skip to content
RCE Write-up Advanced

Exploiting CVE-2024-32002: RCE via Git clone

A vulnerability in Git allows a malicious repository with submodules to write files into the .git directory via a symlink on case-insensitive filesystems, leading to execution of a hook during clone. An attacker could achieve remote code execution when a victim clones the repository recursively.

amalmurali.me

Published on amalmurali.me

A new RCE in Git caught my attention on a recent security feed, labeled CVE-2024-32002. The idea of an RCE being triggered through a simple git clone command fascinated me.

Amal Murali, on amalmurali.me

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, on case-insensitive filesystems, Git incorrectly replaces a directory with a symlink when the path differs only in case, allowing a symlink to point to the .git directory and enabling hook execution.

Impact

An attacker could execute arbitrary code on a victim's machine when they clone a malicious repository recursively, but only on case-insensitive filesystems (Windows and macOS) with symlink support enabled.

What the attacker needed

Victim clones malicious repo recursively; case-insensitive filesystem (Windows/macOS); symlink support enabled

The fix

The vulnerability was fixed by preventing submodule paths from containing symlinks and ensuring directories are not overwritten during clone.

How it was found

  1. Set Git configuration to allow file protocol and symlinks.
  2. Create a hook repository containing a malicious post-checkout hook.
  3. Create a main repository and add the hook repository as a submodule at a path like A/modules/x.
  4. Add a symlink named with a case variation (e.g., a) pointing to .git.
  5. Clone the main repository recursively; the hook executes during the clone.

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 code changes. When you clone a repository, Git may also fetch submodules (nested repositories). This bug lets a malicious repository trick Git into placing a script in a hidden folder that Git runs automatically, so the attacker's code executes on 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.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.