Git Can Steal Your Data: Problem Explained and How to Stay Safe
A vulnerability in Git allows an attacker to craft a submodule path ending with a carriage return, which Git mishandles, causing the submodule to be checked out to an unintended location. If a symlink points that location to the hooks directory and the submodule contains a malicious post-checkout hook, Git executes it with the user's permissions, enabling code execution and data theft.
medium.com
Published on medium.com
Git is used by every developer in open source, in enterprise and even, in their personal projects. It’s been well tested for nearly two decades.
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
Git fails to properly quote a trailing carriage return when writing configuration, and later strips it when reading, leading to path misinterpretation.
Impact
An attacker could run code on the victim's machine, steal data, or move around their network, with the user's permissions.
What the attacker needed
Victim clones a malicious repository; attacker can create symlinks; Git version is vulnerable
The fix
Git should be updated to the latest version, and users should audit submodules and restrict symlink creation.
How it was found
- An attacker adds a submodule path ending with a carriage return in .gitmodules.
- Git fails to quote the carriage return when writing the configuration.
- When Git reads the configuration, it strips the carriage return, altering the path.
- Git checks out the submodule to an unintended location.
- A symlink points that location to a sensitive directory such as .git/hooks.
- The submodule contains a malicious post-checkout hook that Git executes.
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. This bug lets a bad person hide a special invisible character in a project's settings so that when you download the project, Git accidentally runs a harmful script. That script can then do anything you can do on your computer, like steal files.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.