Heap-based Buffer Overflow in vim/vim
Description
A heap-based buffer overflow in vim versions 8.1 and 8.2 allows arbitrary code execution via crafted files or commands.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A heap-based buffer overflow in vim versions 8.1 and 8.2 allows arbitrary code execution via crafted files or commands.
Vulnerability
A heap-based buffer overflow vulnerability exists in vim versions 8.1 and 8.2 when built with --with-features=huge. The flaw resides in the ex_retab() function, triggered by the :retab command with a large argument, leading to invalid memory access [1].
Exploitation
An attacker must convince a user to open a specially crafted file or execute a malicious :retab command. No special network position or authentication is required; user interaction is the primary prerequisite [1].
Impact
Successful exploitation can result in arbitrary code execution within the context of the vim process. If vim is configured to run with elevated privileges (e.g., for editing system configuration files), this could lead to privilege escalation [1].
Mitigation
The vulnerability is fixed in vim patch 8.2.3402 [1]. Users should update to a patched version. There are no known workarounds; however, avoiding running vim with elevated privileges reduces risk.
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
44- osv-coords42 versionspkg:rpm/almalinux/vim-commonpkg:rpm/almalinux/vim-enhancedpkg:rpm/almalinux/vim-filesystempkg:rpm/almalinux/vim-minimalpkg:rpm/almalinux/vim-X11pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.4pkg: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.0pkg: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%20Real%20Time%2015%20SP2pkg: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
< 2:8.0.1763-16.el8_5.13+ 41 more
- (no CPE)range: < 2:8.0.1763-16.el8_5.13
- (no CPE)range: < 2:8.0.1763-16.el8_5.13
- (no CPE)range: < 2:8.0.1763-16.el8_5.13
- (no CPE)range: < 2:8.0.1763-16.el8_5.13
- (no CPE)range: < 2:8.0.1763-16.el8_5.13
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.2.5038-150000.5.21.1
- (no CPE)range: < 8.0.1568-5.17.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.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 9.0.0814-17.9.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.1
- (no CPE)range: < 8.0.1568-5.17.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 when computing character byte length from an invalid UTF-8 character value causes out-of-bounds read."
Attack vector
An attacker can trigger a heap-based buffer overflow by crafting a file containing an invalid UTF-8 byte sequence that causes `find_match_text()` to read past the end of the line buffer [ref_id=1]. The vulnerability is reachable when Vim processes a file with malformed UTF-8 characters during pattern matching, leading to out-of-bounds memory access. No authentication or special privileges are required beyond opening the crafted file in Vim.
Affected code
The heap-buffer-overflow occurs in `find_match_text()` in Vim's regexp engine, specifically in the line `len2 += MB_CHAR2LEN(c2)` which reads beyond the end of the line when an invalid UTF-8 byte sequence is encountered. The patch modifies this line to use `utf_ptr2len()` for UTF-8 encoding to safely compute the byte length instead of relying on `MB_CHAR2LEN(c2)`.
What the fix does
The patch replaces `len2 += MB_CHAR2LEN(c2)` with a conditional that uses `utf_ptr2len(rex.line + col + len2)` when `enc_utf8` is true, otherwise falls back to `MB_CHAR2LEN(c2)` [ref_id=1]. This ensures that for UTF-8 encoding, the actual byte length of the character at the current position is computed by examining the bytes in the buffer rather than deriving the length from the already-read character value `c2`, which could be invalid. The added test case `Test_match_invalid_byte()` writes a file with invalid UTF-8 bytes and sources it to verify the fix.
Preconditions
- inputThe attacker must provide a file containing an invalid UTF-8 byte sequence that Vim will process.
- configVim must be compiled with UTF-8 support (enc_utf8 enabled).
Generated on May 29, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
9- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/7K4JJBIH3OQSZRVTWKCJCDLGMFGQ5DOH/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/S42L4Z4DTW4LHLQ4FJ33VEOXRCBE7WN4/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TE62UMYBZE4AE53K6OBBWK32XQ7544QM/mitrevendor-advisory
- security.gentoo.org/glsa/202208-32mitrevendor-advisory
- www.openwall.com/lists/oss-security/2021/10/01/1mitremailing-list
- lists.debian.org/debian-lts-announce/2022/01/msg00003.htmlmitremailing-list
- github.com/vim/vim/commit/65b605665997fad54ef39a93199e305af2fe4d7fmitre
- huntr.dev/bounties/d9c17308-2c99-4f9f-a706-f7f72c24c273mitre
- security.netapp.com/advisory/ntap-20221118-0003/mitre
News mentions
0No linked articles in our index yet.