A Common Git Command Can Now Run Malicious Code

TL;DR: A newly discovered flaw in Git allows malicious repositories to execute code on your machine. The vulnerability is triggered by the common `git clone --recursive` command, and patches are now available for multiple versions.
Key facts
- Category
- Cybersecurity
- Impact
- Critical
- Published
- Source
- The Hacker News
Full summary
A critical flaw in Git lets malicious repositories execute code on your machine when you clone them with their submodules. Update Git now.
A critical security vulnerability has been discovered and patched in Git, the ubiquitous version control system that underpins modern software development. According to reporting from The Hacker News, the flaw allows a specially crafted, malicious repository to execute arbitrary code on a developer's computer. The attack is triggered during a common and seemingly harmless operation: cloning a repository using the `git clone --recursive` command. This command is frequently used to download a project and all of its declared submodules, which are separate Git repositories nested within a parent project. The Git project has responded swiftly by releasing patched versions, including the new mainline release Git 2.56.1, along with security backports for older series: 2.50.2, 2.51.3, 2.52.1, 2.53.1, 2.54.1, and 2.55.1.
The technical root of this vulnerability is an integer truncation error within Git's handling of its index file. An integer truncation is a classic programming bug where a numerical value is too large for the variable designated to hold it, causing the value to be improperly shortened or "wrapped around." This data corruption can lead to unpredictable and often exploitable program behavior. In this specific scenario, an attacker can create a malicious repository with a carefully designed index. When a victim clones this repository with its submodules, Git processes this malformed index data. The integer truncation bug is triggered, leading to a memory corruption error, likely a buffer overflow. This allows the attacker to write data outside of its intended memory location, overwrite critical program instructions, and ultimately execute their own code on the victim's machine. The attack is particularly dangerous because it is hidden within a standard developer workflow, requiring no user interaction beyond the initial clone command.
This vulnerability is a stark reminder of the increasing focus on the software supply chain as a primary attack vector. Instead of targeting hardened production servers, adversaries are shifting their efforts "left" to compromise the tools and workflows developers use every day. Git, being a foundational element of nearly every software project, represents an extremely high-value target. A successful exploit provides a direct foothold onto a developer's machine, which is a trusted entry point into a company's internal network and codebases. This incident shares a common theme with other supply chain attacks, such as malicious packages being uploaded to registries like npm or PyPI. However, compromising the version control system itself is arguably more fundamental. It weaponizes the very act of fetching source code, subverting the trust developers place in their most essential tools. The involvement of submodules also highlights the complex and often opaque nature of modern software dependencies, where risk can be inherited from upstream projects without direct visibility.
The immediate and most important takeaway for all engineering organizations is the need to patch Git installations without delay. This vulnerability affects developers across all major operating systems—Windows, macOS, and Linux—and extends to any automated systems that interact with Git repositories, such as continuous integration and deployment (CI/CD) pipelines. Security teams should prioritize scanning all developer workstations and build servers for vulnerable Git versions and ensure updates are deployed comprehensively. Beyond the immediate patch, this event should serve as a catalyst for a broader cultural shift. Developers must learn to treat cloning a repository from an untrusted source with the same level of caution as executing an unfamiliar binary. In the long term, we may see the Git ecosystem evolve with enhanced security features, such as sandboxing mechanisms or repository scanning tools that can vet projects before a full clone is initiated. This incident powerfully reinforces the principle of zero trust, extending it from networks and applications all the way down to the source code repositories that form the bedrock of the digital world.
Why it matters
This Git vulnerability represents a significant supply chain security risk. A remote code execution flaw in a core developer tool means cloning an untrusted repository could compromise a developer's machine, providing a foothold for attackers to access internal networks, steal credentials, or inject malicious code into projects.
Business impact
A compromised developer machine is a direct gateway to a company's most valuable assets, including source code and customer data. The immediate business impact is the operational cost of halting work to patch all developer systems, plus the significant risk of intellectual property theft or a wider corporate breach.
⚡ Action needed
Update your Git client to a patched version immediately. The flaw affects multiple recent versions, so check your specific installation and upgrade.
Action checklist
- 1Identify your current Git version (`git --version`).
- 2Upgrade to a patched version (e.g., 2.56.1 or the corresponding security release for your version series).
- 3Audit build servers and CI/CD pipelines that perform recursive clones from untrusted sources.
- 4Advise development teams to be cautious when cloning unfamiliar repositories with submodules.
Related on Notifire
Related stories
Primary source: The Hacker News