CVE-2024-43802
Medium · 4.5CVSS
4.5
EPSS
0.3%
Published
Aug 26, 2024
CISA due date
—
Cloudanix analysis
A rare bug in the Vim text editor can make it crash when certain custom key shortcuts and error messages occur together.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- High
- Impact
- Denial Of Service
- Component
- Application
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Heap-buffer overflow in typeahead buffer handling: flushing moves tb_off outside the valid size of the typebuf variable, allowing later writes in ins_typebuf() to corrupt adjacent heap memory.
Why it matters to the business
Rare crashes in the Vim editor that can interrupt editing sessions; exploitation is difficult and requires specific long mappings plus error conditions, resulting in limited operational impact for most users.
How an attack unfolds
An attacker supplies a crafted set of long key mappings that, when combined with error messages forcing a typeahead buffer flush, advances the internal offset beyond the buffer bounds and triggers a heap overflow on subsequent input processing.
How to fix it
Upgrade Vim to the commit 322ba9108612bead5eb7731ccb66763dec69ef1b (patch v9.1.0697) or later; no workarounds exist.
How to confirm the fix worked
Verify the installed Vim binary reports a version containing commit 322ba9108612bead5eb7731ccb66763dec69ef1b or newer; test that the described mapping-plus-error sequence no longer causes a crash.
Typical attack path
- Define multiple long key mappings in Vim configuration
- Trigger conditions that generate error messages (e.g., invalid commands)
- Cause Vim to flush the typeahead buffer
- Advance tb_off beyond allocated buffer size
- Induce heap-buffer overflow in ins_typebuf leading to crash
How to detect it
Review application logs or core dumps for Vim crashes occurring shortly after error messages while long mappings are active; no public exploitation artifacts are known.
What your security team should do
- Prioritize upgrade of Vim installations to the fixed commit within normal patch cycles
- Monitor upstream Vim releases for any follow-on corrections
- Include Vim version checks in standard software inventory and update processes
The record
Vim is an improved version of the unix vi text editor. When flushing the typeahead buffer, Vim moves the current position in the typeahead buffer but does not check whether there is enough space left in the buffer to handle the next characters. So this may lead to the tb_off position within the typebuf variable to point outside of the valid buffer size, which can then later lead to a heap-buffer overflow in e.g. ins_typebuf(). Therefore, when flushing the typeahead buffer, check if there is enough space left before advancing the off position. If not, fall back to flush current typebuf contents. It's not quite clear yet, what can lead to this situation. It seems to happen when error messages occur (which will cause Vim to flush the typeahead buffer) in comnination with several long mappgins and so it may eventually move the off position out of a valid buffer size. Impact is low since it is not easily reproducible and requires to have several mappings active and run into some error condition. But when this happens, this will cause a crash. The issue has been fixed as of Vim patch v9.1.0697. Users are advised to upgrade. There are no known workarounds for this issue.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Alpine:v3.20 | vim | 0 | 9.1.0707-r0 |
| Alpine:v3.21 | vim | 0 | 9.1.0707-r0 |
| Alpine:v3.22 | vim | 0 | 9.1.0707-r0 |
| Chainguard | vim | 0 | 9.1.0698-r0 |
| Chainguard | vim-doc | 0 | 9.1.0698-r0 |
| Debian:11 | vim | 0 | No fix |
| Debian:11 | vim | 0 | 2:8.2.2434-3+deb11u2 |
| Debian:12 | vim | 0 | No fix |
| Debian:13 | vim | 0 | No fix |
| SUSE:Linux Enterprise Micro 5.1 | vim | 0 | 9.1.1101-150000.5.69.1 |
| SUSE:Linux Enterprise Micro 5.2 | vim | 0 | 9.1.1101-150000.5.69.1 |
| SUSE:Linux Enterprise Micro 5.3 | vim | 0 | 9.1.1101-150000.5.69.1 |
| SUSE:Linux Enterprise Micro 5.4 | vim | 0 | 9.1.1101-150000.5.69.1 |
| SUSE:Linux Enterprise Micro 5.5 | vim | 0 | 9.1.1101-150500.20.21.1 |
| SUSE:Linux Enterprise Module for Basesystem 15 SP6 | vim | 0 | 9.1.1101-150500.20.21.1 |
| SUSE:Linux Enterprise Module for Desktop Applications 15 SP6 | vim | 0 | 9.1.1101-150500.20.21.1 |
| SUSE:Linux Enterprise Server LTSS Extended Security 12 SP5 | vim | 0 | 9.1.1101-17.41.1 |
| Ubuntu:20.04:LTS | vim | 0 | 2:8.1.2269-1ubuntu5.25 |
| Ubuntu:22.04:LTS | vim | 0 | 2:8.2.3995-1ubuntu2.19 |
| Ubuntu:24.04:LTS | vim | 0 | 2:9.1.0016-1ubuntu7.3 |
| Ubuntu:24.10 | vim | 0 | 2:9.1.0496-1ubuntu6 |
| Ubuntu:Pro:14.04:LTS | vim | 0 | 2:7.4.052-1ubuntu3.1+esm19 |
| Ubuntu:Pro:16.04:LTS | vim | 0 | 2:7.4.1689-3ubuntu1.5+esm25 |
| Ubuntu:Pro:18.04:LTS | vim | 0 | 2:8.0.1453-1ubuntu1.13+esm10 |
| Wolfi | vim | 0 | 9.1.0698-r0 |
| Wolfi | vim-doc | 0 | 9.1.0698-r0 |
| openSUSE:Leap 15.6 | vim | 0 | 9.1.1101-150500.20.21.1 |
Related vulnerabilities
- CVE-2024-43374 The UNIX editor Vim prior to version 9.1.0678 has a use-after-free error in argument list… Also affects vim
- CVE-2023-48706 Vim is a UNIX editor that, prior to version 9.0.2121, has a heap-use-after-free… Also affects vim
- CVE-2023-48231 Vim is an open source command line text editor. Also affects vim
- CVE-2023-5535 Use After Free in GitHub repository vim/vim prior to v9.0.2010. Also affects vim
- CVE-2023-5344 Heap-based Buffer Overflow in GitHub repository vim/vim prior to 9.0.1969. Also affects vim
- CVE-2023-4781 Heap-based Buffer Overflow in GitHub repository vim/vim prior to 9.0.1873. Also affects vim
- CVE-2023-4752 Use After Free in GitHub repository vim/vim prior to 9.0.1858. Also affects vim
- CVE-2023-4750 Use After Free in GitHub repository vim/vim prior to 9.0.1857. Also affects vim