Heap-based Buffer Overflow in vim/vim
Description
Heap buffer overflow in Vim's replace command in virtualedit mode allows potential code execution; fixed in 9.0.0483.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Heap buffer overflow in Vim's replace command in virtualedit mode allows potential code execution; fixed in 9.0.0483.
Vulnerability
A heap-based buffer overflow exists in the op_replace function of Vim's source code (prior to version 9.0.0483) when executing replace operations in virtualedit mode. The issue occurs due to insufficient bounds checking when handling cursor positions after editing, particularly with tabs and virtual columns. An attacker can trigger this by crafting a file that, when opened and edited with a replace command, leads to illegal memory access [1].
Exploitation
To exploit, an attacker must convince a user to open a maliciously crafted file and then perform a replace operation while in virtualedit mode. No prior authentication is required, but the user must interact with the editor by executing the replace command. The vulnerable code path is reached when op_replace handles replacement in virtualedit mode, and specifically when the cursor position after replacement is not properly validated [1].
Impact
Successful exploitation can lead to memory corruption, potentially allowing arbitrary code execution in the context of the Vim process. This could enable an attacker to compromise the user's system beyond the editor, depending on the privileges of the Vim session.
Mitigation
The vulnerability is fixed in Vim version 9.0.0483, which includes the commit c249913edc35c0e666d783bfc21595cf9f7d9e0d [1]. Users should upgrade to this version or later. As a workaround, avoid using replace commands in virtualedit mode on untrusted files. The CVE is not listed in CISA's Known Exploited Vulnerabilities catalog.
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
41- osv-coords39 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%20Leap%20Micro%205.3pkg: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%20Micro%205.3pkg: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.0814-150000.5.28.1+ 38 more
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0500-1.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.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.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.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-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.1
- (no CPE)range: < 9.0.0814-150000.5.28.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 bounds check before `PBYTE` write in `op_replace` when virtualedit mode is active allows heap buffer overflow."
Attack vector
An attacker can trigger a heap-based buffer overflow by crafting a file that, when opened and edited with the replace command (`R` or `r`) in virtualedit mode, causes `op_replace` to write past the allocated memory. The bug occurs because the code could call `PBYTE(curwin->w_cursor, c)` without first verifying that the cursor position still points to a valid character (i.e., `gchar_cursor() != NUL`), leading to an illegal memory access [ref_id=1]. The attack requires the victim to open the malicious file and perform a replace operation in virtualedit mode.
Affected code
The vulnerability resides in the `op_replace` function in Vim's source code. The patch modifies the logic that handles character replacement when `virtual_op` (virtualedit mode) is active, specifically around the `PBYTE` macro call and the condition that checks `oap->end.lnum`.
What the fix does
The patch introduces a `done` flag and adds guard checks before the `PBYTE` call. Specifically, it wraps `PBYTE(curwin->w_cursor, c)` inside an `if (gchar_cursor() != NUL)` check, ensuring the cursor still points to a valid character before writing [ref_id=1]. Additionally, the condition for the virtualedit fallback block is changed from `else if` to `if (!done && ...)`, preventing both code paths from executing when the replacement was already handled. These changes prevent the heap buffer overflow by ensuring memory writes only occur when the cursor position is valid.
Preconditions
- inputVictim must open a crafted file in Vim
- configVictim must perform a replace operation (R or r) while virtualedit mode is active
Generated on May 28, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/4QI7AETXBHPC7SGA77Q7O5IEGULWYET7/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GTBVD4J2SKVSWK4VBN5JP5OEVK6GDS3N/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LSSEWQLK55MCNT4Z2IIJEJYEI5HLCODI/mitrevendor-advisory
- security.gentoo.org/glsa/202305-16mitrevendor-advisory
- lists.debian.org/debian-lts-announce/2022/11/msg00009.htmlmitremailing-list
- github.com/vim/vim/commit/c249913edc35c0e666d783bfc21595cf9f7d9e0dmitre
- huntr.dev/bounties/90fdf374-bf04-4386-8a23-38c83b88f0damitre
News mentions
0No linked articles in our index yet.