Heap-based Buffer Overflow in vim/vim
Description
A heap buffer overflow in Vim's Visual mode area adjustment when hiding windows allows potential memory corruption or crash in versions prior to 9.0.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A heap buffer overflow in Vim's Visual mode area adjustment when hiding windows allows potential memory corruption or crash in versions prior to 9.0.
Vulnerability
A heap-based buffer overflow exists in Vim's handling of Visual mode when the Visual area ends after the end of a line and the :hide command is used, leading to a memory access beyond the allocated buffer. The issue is present in Vim versions prior to 9.0, specifically when win_close() is called without resetting the Visual selection, causing a read beyond the line's memory. [1]
Exploitation
An attacker would need to convince a user to open a specially crafted file in Vim and perform a sequence of operations that trigger the Visual area adjustment after :hide. The attacker does not require network access; the exploit is triggered via local file editing. The specific steps involve setting a Visual selection that extends beyond the end of a line, then hiding a window, which triggers the vulnerable code path. [1]
Impact
Successful exploitation could cause a heap-based buffer overflow, potentially leading to information disclosure (reading beyond line bounds) or a denial of service due to memory corruption. No remote code execution has been demonstrated, but the overflow could corrupt heap data. [1]
Mitigation
The vulnerability is fixed in Vim version 9.0.0017 and later. Users should upgrade to Vim 9.0 or apply the patch from the commit [1]. Gentoo users can upgrade to >=app-editors/vim-9.0.0060 (or gvim and vim-core equivalents) as per GLSA 202208-32 [4]. There is no known workaround other than upgrading.
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
39- osv-coords37 versionspkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%20Micro%205.2pkg: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
< 9.0.0313-150000.5.25.1+ 36 more
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0453-2.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.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: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.1
- (no CPE)range: < 9.0.0313-150000.5.25.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 reset of Visual mode before closing a window allows heap-buffer over-read/write when the Visual area extends beyond the end of the line."
Attack vector
An attacker can trigger a heap-based buffer overflow by crafting a Vim script or input that causes Visual mode to be active when a window is closed via `:hide`. The Visual area may end after the end of the line (as shown in the test `Test_visual_area_adjusted_when_hiding`), and when the window is closed without resetting Visual mode, subsequent operations (e.g., `norm! zW`) can read or write beyond the allocated line buffer. The attack requires the victim to open a file and execute the crafted sequence, which can be delivered through a malicious text file or Vim plugin.
Affected code
The vulnerability is in the Vim source file `win_close()` (around line 2594). The patch adds a call to `reset_VIsual_and_resel()` before closing a window when the buffer being closed is not the current buffer (`wp->w_buffer != curbuf`). No other function or file is identified as the root cause.
What the fix does
The patch adds a call to `reset_VIsual_and_resel()` in `win_close()` before applying autocommands when the closing window's buffer differs from the current buffer. This ensures Visual mode is properly terminated before the window is hidden, preventing subsequent operations from accessing memory beyond the end of the line. The included test (`Test_visual_area_adjusted_when_hiding`) reproduces the scenario where a Visual area ends after the end of the line and verifies the fix.
Preconditions
- inputVictim must open a file in Vim and execute a crafted sequence (e.g., via a malicious text file or plugin) that triggers Visual mode followed by :hide.
- inputThe Visual area must end after the end of the line (e.g., using blockwise Visual mode with $ to extend past the line end).
Generated on May 28, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/43Y3VJPOTTY3NTREDIFUPITM2POG4ZLP/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/UXPO5EHDV6J4B27E65DOQGZFELUFPRSK/mitrevendor-advisory
- security.gentoo.org/glsa/202208-32mitrevendor-advisory
- security.gentoo.org/glsa/202305-16mitrevendor-advisory
- github.com/vim/vim/commit/3d51ce18ab1be4f9f6061568a4e7fabf00b21794mitre
- huntr.dev/bounties/571d25ce-8d53-4fa0-b620-27f2a8a14874mitre
News mentions
0No linked articles in our index yet.