CVE-2026-28421
Vim vulnerability analysis and mitigation

Overview

CVE-2026-28421 is a heap-buffer-overflow and segmentation fault (SEGV) vulnerability in Vim's swap file recovery logic, affecting all versions prior to 9.2.0077. The flaws are caused by unvalidated fields read from crafted pointer blocks within a swap file during the ml_recover() operation. It was disclosed on February 27, 2026, by GitHub users ehdgks0627 and un3xploitable, with a fix released the same day in Vim v9.2.0077. The vulnerability carries a CVSS v3.1 base score of 7.8 (High) per NVD, though the GitHub Security Advisory rates it as Moderate (5.3) (GitHub Advisory, Openwall OSS-Sec).

Technical details

The root cause is improper input validation (CWE-20) leading to a heap-based buffer overflow (CWE-122) in src/memline.c. During swap file recovery, ml_recover() reads pointer block fields (pe_bnum, pe_page_count, pe_old_lnum, pe_line_count) directly from the untrusted swap file without bounds checking. Two distinct attack paths exist: (1) Heap Overflow — a crafted swap file with bogus pe_bnum or pe_page_count values exceeding the swap file size causes mf_get() to fail; repeated triggering of the ml_append() fallback overflows the db_index array in the current data block, potentially enabling arbitrary code execution; (2) SEGV — a negative pe_bnum causes Vim to call readfile() with unvalidated pe_old_lnum and pe_line_count values, resulting in a segmentation fault. The fix adds bounds checks on pe_page_count and pe_bnum against mf_blocknr_max, and validates pe_old_lnum >= 1 and pe_line_count > 0 before calling readfile() (GitHub Commit, GitHub Advisory).

Impact

Successful exploitation can result in a crash (denial of service via segmentation fault) or potentially arbitrary code execution in the context of the user running Vim. An attacker who can place a crafted .swp file in a location accessible to the victim — such as a shared project directory or version-controlled repository — can trigger the vulnerability when the victim attempts to recover the file. Confidentiality, integrity, and availability are all potentially impacted, though the practical severity depends on whether the heap overflow can be reliably weaponized for code execution beyond a crash (GitHub Advisory, Openwall OSS-Sec).

Exploitation steps

  1. Craft a malicious swap file: Create a .swp file with manipulated pointer block fields — set pe_bnum to a value exceeding mf_blocknr_max or to a negative value, and set pe_page_count to an extremely large value (e.g., 0x40000000) to trigger a multi-GB allocation attempt, or set pe_old_lnum/pe_line_count to garbage values for the SEGV path.
  2. Deliver the swap file: Place the crafted .swp file in a location the victim will encounter it — e.g., a shared project directory, a cloned Git repository, or a network share. The file should be named to match a file the victim is likely to edit (e.g., Xpoc1.swp for a file named Xpoc1).
  3. Trigger recovery: Wait for the victim to open Vim in the directory containing the swap file, or directly open the associated filename. Vim will detect the swap file and prompt for recovery. When the victim selects 'Recover', ml_recover() processes the malicious pointer blocks.
  4. Achieve crash or code execution: For the heap overflow path, repeated triggering of the ml_append() fallback overflows the db_index array, potentially enabling arbitrary code execution. For the SEGV path, Vim crashes immediately due to invalid parameters passed to readfile() (GitHub Advisory, GitHub Commit).

Indicators of compromise

  • File System: Unexpected .swp files in shared directories, project repositories, or working directories — particularly files with unusual sizes or timestamps inconsistent with normal Vim usage; presence of recover-crash1.swp or recover-crash2.swp filenames.
  • Process: Vim process terminating abnormally with a segmentation fault (exit code 139 / signal 11 on Linux); core dump files (core, core.<pid>) generated in the working directory after a Vim recovery attempt.
  • Logs: System logs (e.g., /var/log/syslog, journalctl) showing segfault entries for the vim process; application crash reports referencing ml_recover or memline.c in stack traces.
  • Network/Shared Storage: Unexpected .swp files appearing in shared network directories or version control repositories that were not created by legitimate Vim sessions.

Mitigation and workarounds

The primary remediation is to upgrade Vim to version 9.2.0077 or later, which adds bounds checks on all untrusted swap file fields before use (GitHub Release). Downstream distributions including Red Hat Enterprise Linux, Ubuntu (USN-8101-1), Fedora, Mageia, Amazon Linux 2023, and others have released updated packages incorporating this fix (Red Hat Advisory, Ubuntu Advisory). As a workaround where patching is not immediately possible, restrict access to shared directories to prevent untrusted swap files from being placed there, and advise users to exercise caution when Vim prompts for swap file recovery — particularly for files from untrusted or shared sources. IBM API Connect users should also apply the relevant IBM fix (IBM Advisory).

Community reactions

The vulnerability was disclosed responsibly by GitHub users ehdgks0627 and un3xploitable, with the Vim maintainer Christian Brabandt publishing the fix and coordinated disclosure simultaneously on February 27, 2026, via the oss-security mailing list and GitHub Security Advisory (Openwall OSS-Sec). A Medium article titled "Vim's Partial Patch Problem: 14 Heap Overflows Left Behind After CVE-2026-28421" raised community discussion about whether the fix was comprehensive, suggesting additional heap overflow cases may remain unaddressed (Medium). The vulnerability received broad coverage across Linux distribution security channels, with rapid patch uptake across major distributions.

Additional resources


SourceThis report was generated using AI

Related Vim vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-59858HIGH8.4
  • Vim logoVim
  • vim-enhanced
NoYesJul 09, 2026
CVE-2026-59856HIGH8.4
  • Vim logoVim
  • vim
NoYesJul 09, 2026
CVE-2026-57456HIGH8.4
  • Vim logoVim
  • vim-common
NoYesJun 25, 2026
CVE-2026-59857MEDIUM5.6
  • Vim logoVim
  • xxd
NoYesJul 09, 2026
CVE-2026-57455MEDIUM4
  • Vim logoVim
  • vim-filesystem
NoYesJun 25, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management