Git Before 2.30.6 RCE via git-shell Argument Overflow
CVE-2022-39260 Published on October 19, 2022
Git vulnerable to Remote Code Execution via Heap overflow in `git shell`
Git is an open source, scalable, distributed revision control system. `git shell` is a restricted login shell that can be used to implement Git's push/pull functionality via SSH. In versions prior to 2.30.6, 2.31.5, 2.32.4, 2.33.5, 2.34.5, 2.35.5, 2.36.3, and 2.37.4, the function that splits the command arguments into an array improperly uses an `int` to represent the number of entries in the array, allowing a malicious actor to intentionally overflow the return value, leading to arbitrary heap writes. Because the resulting array is then passed to `execv()`, it is possible to leverage this attack to gain remote code execution on a victim machine. Note that a victim must first allow access to `git shell` as a login shell in order to be vulnerable to this attack. This problem is patched in versions 2.30.6, 2.31.5, 2.32.4, 2.33.5, 2.34.5, 2.35.5, 2.36.3, and 2.37.4 and users are advised to upgrade to the latest version. Disabling `git shell` access via remote logins is a viable short-term workaround.
Vulnerability Analysis
CVE-2022-39260 is exploitable with network access, and requires small amount of user privileges. This vulnerability is consided to have a high level of attack complexity. The potential impact of an exploit of this vulnerability is considered to be very high.
Weakness Types
What is a Memory Corruption Vulnerability?
The software writes data past the end, or before the beginning, of the intended buffer. Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
CVE-2022-39260 has been classified to as a Memory Corruption vulnerability or weakness.
Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
Products Associated with CVE-2022-39260
You can be notified by email with stack.watch whenever vulnerabilities like CVE-2022-39260 are published in these products:
Affected Versions
git:- Version < 2.30.6 is affected.
- Version > 2.31.0, < 2.31.5 is affected.
- Version > 2.32.0, < 2.32.4 is affected.
- Version > 2.33.0, < 2.33.5 is affected.
- Version > 2.34.0, < 2.34.5 is affected.
- Version > 2.34.0, < 2.35.5 is affected.
- Version > 2.35.0, < 2.36.3 is affected.
- Version > 2.37.0, < 2.37.4 is affected.
Exploit Probability
EPSS (Exploit Prediction Scoring System) scores estimate the probability that a vulnerability will be exploited in the wild within the next 30 days. The percentile shows you how this score compares to all other vulnerabilities.