Expand file tree
Git honours configuration directives such as core.fsmonitor inside a repository's .git/config, and a bare repository can be buried inside a regular repository so that running git status in a subdirectory executes an attacker-chosen command. Software that opportunistically runs git against an untrusted directory, including several IDEs, shell prompt decorations and Git pillaging tools, can therefore be made to run arbitrary code on the user's machine.
Published on github.com
History
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 the design decision that a repository's own .git/config may specify commands to execute, combined with software that runs git against directories the user has not chosen to trust.
Impact
An attacker could achieve arbitrary code execution on the machine of anyone whose IDE, shell prompt or pillaging tool runs git against the crafted directory; some tools have since added trust prompts or overrides, and Git 2.38.0 added an opt-in mitigation.
What the attacker needed
Victim runs git in the crafted directory; software runs git without a trust prompt
The fix
Git should be configured with safe.bareRepository set to explicit, and integrating software should require the user to trust a workspace before running git in it.
How it was found
- Clone a repository that contains a buried bare repository with a malicious config
- Change into the malicious subdirectory
- Run git status there, which triggers the configured command
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 stores a project's settings in a hidden folder called .git, and some of those settings tell Git to run a command. If someone hands you a folder containing a crafted .git folder and a program runs Git inside it, that command runs on your computer. The report shows that many editors and terminal prompts do exactly this without asking, so opening or even just changing into the wrong folder can be enough.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.