CVE-2022-2042
High · 7.8CVSS
7.8
EPSS
1.5%
Published
Jun 10, 2022
CISA due date
—
Cloudanix analysis
A flaw in the popular Vim text editor could let an attacker take control of a computer when someone opens a specially crafted file.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Low
- Impact
- Full Compromise
- Component
- Application
- Class
- Use After Free
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Use-after-free condition in Vim allows an attacker to access freed memory during text processing, enabling arbitrary code execution with the privileges of the Vim process.
Why it matters to the business
Attackers with local access and a malicious file can achieve full system compromise on developer and administrator workstations running vulnerable Vim versions; the issue has been public for over four years with working exploits available, increasing long-term risk for any environment still using unpatched Vim.
How an attack unfolds
An attacker crafts a specially formatted file that triggers the use-after-free during Vim's internal buffer handling. When a user opens the file in an affected Vim build, the freed memory is reused, allowing the attacker to overwrite function pointers or data structures and execute arbitrary code.
How to fix it
Upgrade vim/vim to the commit 98056533b96b6b5d8849641de93185dd7bcadc44 or later; rebuild and redeploy any locally compiled Vim instances or distributions that bundle the vulnerable version.
How to confirm the fix worked
Run 'vim --version' and confirm the build includes commit 98056533b96b6b5d8849641de93185dd7bcadc44 or is newer than 8.2; test with known proof-of-concept files in a sandbox to verify the crash or exploitation behavior is no longer present.
Typical attack path
- Create or obtain a malicious file designed to trigger the use-after-free in Vim
- Deliver the file to the target via email, download, or shared storage
- Victim opens the file using a vulnerable Vim binary (local, no network required)
- Vim processes the file and reuses the freed memory region
- Attacker-controlled data leads to code execution and potential privilege escalation or persistence
How to detect it
Review system and application logs for unexpected Vim crashes or abnormal memory access patterns when opening files; correlate with process execution of vim or gvim on endpoints where untrusted files may have been opened.
What your security team should do
- Immediately inventory all systems for Vim versions prior to the fixed commit and prioritize patching developer and server environments
- Block or sandbox untrusted file handling in Vim until upgrades are complete
- Monitor vulnerability disclosure feeds for any new exploit publications given the existing ExploitAvailable maturity
The record
Use After Free in GitHub repository vim/vim prior to 8.2.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Debian:11 | vim | 0 | No fix |
| Debian:12 | vim | 0 | 2:9.0.0135-1 |
| Debian:13 | vim | 0 | 2:9.0.0135-1 |
| Mageia:8 | vim | 0 | 9.0.828-1.mga8 |
| Ubuntu:20.04:LTS | vim | 0 | 2:8.1.2269-1ubuntu5.21 |
| Ubuntu:22.04:LTS | vim | 0 | 2:8.2.3995-1ubuntu2.15 |
| Ubuntu:23.10 | vim | 0 | 2:9.0.1672-1ubuntu2.2 |
| Ubuntu:Pro:14.04:LTS | vim | 0 | 2:7.4.052-1ubuntu3.1+esm15 |
| Ubuntu:Pro:16.04:LTS | vim | 0 | 2:7.4.1689-3ubuntu1.5+esm7 |
| Ubuntu:Pro:16.04:LTS | vim | 0 | 2:7.4.1689-3ubuntu1.5+esm22 |
| Ubuntu:Pro:18.04:LTS | vim | 0 | 2:8.0.1453-1ubuntu1.13+esm7 |
| openSUSE:Tumbleweed | vim | 0 | 9.0.0453-2.1 |
Related vulnerabilities
- CVE-2025-29768 Vim, a text editor, is vulnerable to potential data loss with zip.vim and special crafted… Also affects vim
- CVE-2025-27423 Vim is an open source, command line text editor. Also affects vim
- CVE-2025-24014 Vim is an open source, command line text editor. Also affects vim
- CVE-2025-22134 When switching to other buffers using the :all command and visual mode still being… Also affects vim
- CVE-2024-47814 Vim is an open source, command line text editor. Also affects vim
- CVE-2024-43802 Vim is an improved version of the unix vi text editor. Also affects vim
- 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-2024-22667 Vim before 9.0.2142 has a stack-based buffer overflow because did_set_langmap in map.c… Also affects vim