CVE-2024-43374
Medium · 4.5CVSS
4.5
EPSS
0.4%
Published
Aug 16, 2024
CISA due date
—
Cloudanix analysis
A bug in the Vim text editor can make the program crash if someone loads a specially crafted plugin, but it cannot be used to steal data or take control of the computer.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- High
- Impact
- Denial Of Service
- Component
- Application
- Class
- Use After Free
- Remediation
- Patch
- Effort
- Low
- Patch risk
- Low
What it actually does
Use-after-free in Vim argument list handling: Buf* autocommands triggered on new file addition can close the newly created buffer/window, freeing the window structure that still holds a reference to the argument list being modified; subsequent access after autocommand completion uses the dangling reference.
Why it matters to the business
May cause Vim to crash when a user sources a malicious plugin or unusual autocommands, leading to loss of unsaved work and workflow interruption; impact remains low because exploitation requires deliberate or malicious configuration and no remote code execution or data theft is possible.
How an attack unfolds
An attacker crafts a Vim plugin or configuration that registers Buf* autocommands to delete the buffer and its window during argument-list insertion; once the autocommands finish, Vim dereferences the now-freed window and argument-list pointers, resulting in a crash.
How to fix it
Upgrade Vim to version 9.1.0678 or later (commit 0a6e57b09bc8c76691b367a5babfb79b31b770e8). Rebuild from source or obtain updated packages from distribution maintainers. Review and remove any third-party plugins that manipulate buffers inside Buf* autocommands during argument-list operations.
How to confirm the fix worked
Run 'vim --version' and confirm the patch level is at least 9.1.0678. Test the reproducer by sourcing a minimal autocommand that wipes the buffer on BufNew and then adding a file to the argument list; the editor should no longer crash.
Typical attack path
- User opens Vim with a malicious plugin or autocommand file sourced
- Plugin registers Buf* autocommands that wipe the buffer on creation
- User or script adds a new file to the argument list
- Autocommands fire, closing the buffer and freeing the window structure
- Vim continues argument-list modification using the now-invalid references
- Process crashes due to use-after-free
How to detect it
Examine system and application logs for unexpected Vim segmentation faults or aborts around the time users report editor instability; correlate with recent sourcing of unknown .vim files or plugins. No network or file-based IOCs are known because the flaw requires local configuration.
What your security team should do
- Prioritize patching Vim instances that allow user-supplied plugins or configurations
- Audit plugin directories for any code registering Buf* autocommands that delete buffers
- Block execution of untrusted .vim files and plugins via organizational policy
- Monitor for new Vim releases and automate version checks in developer environments
The record
The UNIX editor Vim prior to version 9.1.0678 has a use-after-free error in argument list handling. When adding a new file to the argument list, this triggers `Buf*` autocommands. If in such an autocommand the buffer that was just opened is closed (including the window where it is shown), this causes the window structure to be freed which contains a reference to the argument list that we are actually modifying. Once the autocommands are completed, the references to the window and argument list are no longer valid and as such cause an use-after-free. Impact is low since the user must either intentionally add some unusual autocommands that wipe a buffer during creation (either manually or by sourcing a malicious plugin), but it will crash Vim. The issue has been fixed as of Vim patch v9.1.0678.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Alpine:v3.20 | vim | 0 | 9.1.0678-r0 |
| Alpine:v3.21 | vim | 0 | 9.1.0678-r0 |
| Alpine:v3.22 | vim | 0 | 9.1.0678-r0 |
| Chainguard | vim | 0 | 9.1.0686-r0 |
| Chainguard | vim-doc | 0 | 9.1.0686-r0 |
| Debian:11 | vim | 0 | No fix |
| Debian:12 | vim | 0 | No fix |
| Debian:13 | vim | 0 | No fix |
| Debian:14 | vim | 0 | 2:9.1.0698-1 |
| Mageia:9 | vim | 0 | 9.1.719-1.mga9 |
| SUSE:Linux Enterprise Micro 5.5 | vim | 0 | 9.1.0836-150500.20.15.1 |
| SUSE:Linux Enterprise Module for Basesystem 15 SP5 | vim | 0 | 9.1.0836-150500.20.15.1 |
| SUSE:Linux Enterprise Module for Basesystem 15 SP6 | vim | 0 | 9.1.0836-150500.20.15.1 |
| SUSE:Linux Enterprise Module for Desktop Applications 15 SP5 | vim | 0 | 9.1.0836-150500.20.15.1 |
| SUSE:Linux Enterprise Module for Desktop Applications 15 SP6 | vim | 0 | 9.1.0836-150500.20.15.1 |
| SUSE:Linux Enterprise Server 12 SP5-LTSS | vim | 0 | 9.1.0836-17.38.1 |
| SUSE:Linux Enterprise Server LTSS Extended Security 12 SP5 | vim | 0 | 9.1.0836-17.38.1 |
| Ubuntu:20.04:LTS | vim | 0 | 2:8.1.2269-1ubuntu5.24 |
| Ubuntu:22.04:LTS | vim | 0 | 2:8.2.3995-1ubuntu2.18 |
| Ubuntu:24.04:LTS | vim | 0 | 2:9.1.0016-1ubuntu7.2 |
| Ubuntu:Pro:14.04:LTS | vim | 0 | 2:7.4.052-1ubuntu3.1+esm18 |
| Ubuntu:Pro:16.04:LTS | vim | 0 | 2:7.4.1689-3ubuntu1.5+esm24 |
| Ubuntu:Pro:18.04:LTS | vim | 0 | 2:8.0.1453-1ubuntu1.13+esm9 |
| Wolfi | vim | 0 | 9.1.0686-r0 |
| Wolfi | vim-doc | 0 | 9.1.0686-r0 |
| openSUSE:Leap 15.5 | vim | 0 | 9.1.0836-150500.20.15.1 |
| openSUSE:Leap 15.6 | vim | 0 | 9.1.0836-150500.20.15.1 |
| openSUSE:Leap Micro 5.5 | vim | 0 | 9.1.0836-150500.20.15.1 |
Related vulnerabilities
- CVE-2024-43802 Vim is an improved version of the unix vi text editor. 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