Heap-based Buffer Overflow in vim/vim
Description
A heap-based buffer overflow in vim's status line rendering can be triggered by an overlong file name, potentially leading to memory corruption.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A heap-based buffer overflow in vim's status line rendering can be triggered by an overlong file name, potentially leading to memory corruption.
Vulnerability
CVE-2022-0213 describes a heap-based buffer overflow in vim. The flaw resides in the status line rendering code, specifically in the NameBuff handling within win_redr_status(). When a file with an extremely long name is opened and the status line is redrawn (e.g., on :redraw! or certain modeline actions), the code can write beyond the allocated buffer NameBuff. The overflow is triggered in versions prior to patch 8.2.4074 [2].
Exploitation
An attacker would need to provide a crafted file with an overlong file name and entice the user to open it in vim. The user must then trigger a status line redraw (e.g., by switching windows or using :redraw!). The attacker does not require any special network position or authentication beyond being able to serve or send the file to the victim. The overflow occurs when the code appends a space character to indicate buffer status (help, preview, changed, readonly) without first checking that len < MAXPATHL - 1 [2].
Impact
Successful exploitation results in a heap-based buffer overflow, which can corrupt adjacent heap memory. This may cause a crash (denial of service) or, in theory, allow arbitrary code execution, though the complexity of controlling the overwritten data is high. In the context of vim, an attacker could potentially execute arbitrary commands with the privileges of the vim process [1].
Mitigation
The fix is included in vim patch 8.2.4074, released on 2021-10-04 [2]. Users should upgrade to vim version 9.0.0060 or later to receive all cumulative fixes [3]. There is no known workaround; however, users can mitigate risk by not opening untrusted files in vim or by using a tool like view in read-only mode [3].
AI Insight generated on May 27, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
38- osv-coords36 versionspkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/vim&distro=openSUSE%20Tumbleweedpkg:rpm/suse/vim&distro=SUSE%20Enterprise%20Storage%206pkg:rpm/suse/vim&distro=SUSE%20Enterprise%20Storage%207pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-ESPOSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP1-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-ESPOSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015%20SP2-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-ESPOSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20High%20Performance%20Computing%2015-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Micro%205.1pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Micro%205.2pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP3pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP4pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Desktop%20Applications%2015%20SP3pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Desktop%20Applications%2015%20SP4pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP2-BCLpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP3-BCLpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP4-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP1-BCLpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP1-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP2-BCLpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2015%20SP2-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2015-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP4pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2012%20SP5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP1pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%20for%20SAP%20Applications%2015%20SP2pkg:rpm/suse/vim&distro=SUSE%20Manager%20Proxy%204.1pkg:rpm/suse/vim&distro=SUSE%20Manager%20Retail%20Branch%20Server%204.1pkg:rpm/suse/vim&distro=SUSE%20Manager%20Server%204.1pkg:rpm/suse/vim&distro=SUSE%20OpenStack%20Cloud%209pkg:rpm/suse/vim&distro=SUSE%20OpenStack%20Cloud%20Crowbar%209
< 8.2.5038-150000.5.21.1+ 35 more
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 9.0.0453-2.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
Patches
0No patches discovered yet.
Vulnerability mechanics
Root cause
"Missing length check before appending a space character to NameBuff allows writing past the buffer's end when the filename already fills the buffer."
Attack vector
An attacker can trigger a heap-based buffer overflow by opening a file whose name is exactly MAXPATHL-1 characters long (or longer) in a buffer that satisfies one of the conditions checked in win_redr_status: help buffer, preview window, changed buffer, or readonly buffer [ref_id=1]. When the status line is redrawn, the code appends a space character to NameBuff without verifying that there is room, writing one byte past the allocated buffer [ref_id=1]. The overflow occurs during normal editor operations such as redrawing the status line, which can be triggered by window layout changes or the `:redraw!` command [ref_id=1].
Affected code
The vulnerable code is in the `win_redr_status` function in the Vim source, where `NameBuff` is used without a length check before appending a space character [ref_id=1]. The patch modifies the condition at line 465 of the original diff to add `&& len < MAXPATHL - 1` before the space is written [ref_id=1].
What the fix does
The patch adds a length check `len < MAXPATHL - 1` before appending the space character to NameBuff, ensuring the buffer does not overflow [ref_id=1]. The condition is combined with the existing checks for help buffer, preview window, changed buffer, and readonly buffer using an AND operator, so the space is only appended when there is room [ref_id=1]. A new test function `Test_edit_overlong_file_name` was also added to verify the fix by creating a file with a very long name and redrawing the status line [ref_id=1].
Preconditions
- inputA file with a name of length MAXPATHL-1 or longer must exist and be opened in the editor.
- configThe buffer must be a help buffer, preview window, changed buffer, or readonly buffer (or the editor must be compiled with FEAT_QUICKFIX and the window have the preview flag set).
- networkNo network access required; the attack is local.
Generated on May 27, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- security.gentoo.org/glsa/202208-32mitrevendor-advisory
- www.openwall.com/lists/oss-security/2022/01/15/1mitremailing-list
- lists.debian.org/debian-lts-announce/2022/03/msg00018.htmlmitremailing-list
- lists.debian.org/debian-lts-announce/2022/11/msg00009.htmlmitremailing-list
- github.com/vim/vim/commit/de05bb25733c3319e18dca44e9b59c6ee389eb26mitre
- huntr.dev/bounties/f3afe1a5-e6f8-4579-b68a-6e5c7e39afedmitre
News mentions
0No linked articles in our index yet.