Vulnerability record · CVE-2022-23521 · published 17 January 2023
CVE-2022-23521: Git gitattributes parsing integer overflow enables heap corruption
Git Scm · Git
Git's gitattributes parser suffers multiple integer overflows when handling a huge number of path patterns, many attributes for one pattern, or very long attribute names. A crafted .gitattributes file, including one already in commit history, can trigger the overflow, and because Git splits long lines only when reading from a file and not from the index, the failure mode varies by where the file exists. The flaw can cause arbitrary heap reads and writes, potentially leading to remote code execution.
Description
Git is distributed revision control system. gitattributes are a mechanism to allow defining attributes for paths. These attributes can be defined by adding a `.gitattributes` file to the repository, which contains a set of file patterns and the attributes that should be set for paths matching this pattern. When parsing gitattributes, multiple integer overflows can occur when there is a huge number of path patterns, a huge number of attributes for a single pattern, or when the declared attribute names are huge. These overflows can be triggered via a crafted `.gitattributes` file that may be part of the commit history. Git silently splits lines longer than 2KB when parsing gitattributes from a file, but not when parsing them from the index. Consequentially, the failure mode depends on whether the file exists in the working tree, the index or both. This integer overflow can result in arbitrary heap reads and writes, which may result in remote code execution. The problem has been patched in the versions published on 2023-01-17, going back to v2.30.7. Users are advised to upgrade. There are no known workarounds for this issue.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Automated analysis
critical priorityCVSS 9.8 with network reachability, no authentication or user interaction, and potential remote code execution, combined with a very high EPSS score, makes this a critical patching priority.
What it is
Git's gitattributes parser suffers multiple integer overflows when handling a huge number of path patterns, many attributes for one pattern, or very long attribute names. A crafted .gitattributes file, including one already in commit history, can trigger the overflow, and because Git splits long lines only when reading from a file and not from the index, the failure mode varies by where the file exists. The flaw can cause arbitrary heap reads and writes, potentially leading to remote code execution.
Impact
An attacker can corrupt heap memory, leading to arbitrary reads and writes and potentially remote code execution in the context of the Git process. This can compromise the repository, the developer's machine, or any system processing the malicious repository.
Attack surface
The vulnerability is network-reachable with no privileges or user interaction required per the CVSS vector, and is triggered by processing a repository containing a crafted .gitattributes file. It can be reached through normal Git operations such as cloning, fetching, or checking out a malicious repository.
Exploitation
The CVE is not listed in CISA KEV and no ransomware use is documented; EPSS gives a 30-day exploitation probability of 0.563 (99th percentile), and the references include a patch and vendor advisory but no public exploit tag.
What to do
- Upgrade Git to a version published on or after 2023-01-17, at minimum v2.30.7 or newer, as the issue is patched there.
- Apply the vendor patch commit 508386c6c5857b4faa2c3e491f422c98cc69ae76 if building from source.
- Treat untrusted repositories as hostile: avoid cloning or checking out repositories from untrusted sources until patched.
- Monitor Git security advisories and distribution packages (for example Gentoo GLSA 202312-15) for updated builds.
- There are no known workarounds, so patching is the only effective remediation.
Detection
- Scan repositories for unusually large or malformed .gitattributes files, especially those with very long lines or an excessive number of patterns or attributes.
- Monitor Git process crashes or memory errors during clone, fetch, or checkout operations, which may indicate exploitation attempts.
- Audit commit history for .gitattributes files that were added or modified in unexpected ways, since the file may be part of the commit history.
- Use endpoint detection to flag abnormal memory access patterns or code execution originating from Git processes handling untrusted repositories.
This assessment is produced automatically and is not human-reviewed. Verify against the vendor advisory before acting on it.
Affected products
1 vulnerable configurations from NVD's CPE data, grouped by vendor and product.
References
| Link | Tags |
|---|---|
| https://github.com/git/git/commit/508386c6c5857b4faa2c3e491f422c98cc69ae76 | PatchThird Party Advisory |
| https://github.com/git/git/security/advisories/GHSA-c738-c5qq-xg89 | Third Party Advisory |
| https://security.gentoo.org/glsa/202312-15 | |
| https://github.com/git/git/commit/508386c6c5857b4faa2c3e491f422c98cc69ae76 | PatchThird Party Advisory |
| https://github.com/git/git/security/advisories/GHSA-c738-c5qq-xg89 | Third Party Advisory |
| https://security.gentoo.org/glsa/202312-15 |
Track CVE-2022-23521 inside VULONE
Watch it alongside the ransomware crews, C2 infrastructure and forum chatter that reference it, query it through the API and pull it into your SIEM over TAXII.
Related vulnerabilities
Same products first, then exploited flaws of the same weakness class.
Source: NIST National Vulnerability Database (record CVE-2022-23521), CISA KEV, FIRST EPSS (scores of 2026-09-26). This page is refreshed as NVD updates the record.