use-after-free when closing buffers in Vim
Description
A use-after-free in Vim before 9.1.0764 allows a crash when a BufWinLeave autocmd reopens a buffer in a new split window during buffer close.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A use-after-free in Vim before 9.1.0764 allows a crash when a BufWinLeave autocmd reopens a buffer in a new split window during buffer close.
Vulnerability
A use-after-free vulnerability exists in Vim versions prior to 9.1.0764 [1]. When a buffer visible in a window is closed, a BufWinLeave autocommand can cause the buffer to be freed while still referenced, if the autocommand re-opens the same buffer in a new split window. Vim detects simple cases such as au BufWinLeave foobar :vsp foobar and aborts with E1159, but a more complex sequence (editing another file then splitting to re-edit the original) can bypass this check and confuse reference counting, leading to a use-after-free [1]. The issue is triggered only when a user intentionally configures such an autocommand and runs buffer unload commands [1][2].
Exploitation
An attacker needs to craft a BufWinLeave autocommand that, when triggered during buffer close, executes a sequence like :e dummy | vsp originalbuffer. This causes Vim to free the buffer structure while it is still referenced in another window [1]. The user must set up this autocommand in their configuration (e.g., in .vimrc or via an -S script) and then close the buffer (e.g., with :bw) [1][2]. No network access or special privileges are required, only local ability to run Vim with the malicious configuration [1].
Impact
Successful exploitation leads to a use-after-free, which typically causes a crash (denial of service) [1][2]. The advisory rates impact as low because it requires the user to have intentionally set up a strange autocommand [1]. However, in theory, a crafted autocommand could lead to memory corruption beyond a crash, though no such exploit is demonstrated in the references [1][2].
Mitigation
The vulnerability is fixed in Vim version 9.1.0764, released on October 6, 2024 [1][2]. Users should upgrade to this version or later. There are no known workarounds [1]. The patch adds a buf_locked() function and checks to abort if the buffer is locked during do_ecmd, preventing the use-after-free [2].
AI Insight generated on May 25, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
17- osv-coords15 versionspkg:apk/chainguard/vimpkg:apk/chainguard/vim-docpkg:apk/wolfi/vimpkg:apk/wolfi/vim-docpkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.5pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%2015.6pkg:rpm/opensuse/vim&distro=openSUSE%20Leap%20Micro%205.5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Micro%205.5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Basesystem%2015%20SP6pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Desktop%20Applications%2015%20SP5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Module%20for%20Desktop%20Applications%2015%20SP6pkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%2012%20SP5-LTSSpkg:rpm/suse/vim&distro=SUSE%20Linux%20Enterprise%20Server%20LTSS%20Extended%20Security%2012%20SP5pkg:rpm/suse/vim&distro=SUSE%20Linux%20Micro%206.0
< 9.1.0766-r0+ 14 more
- (no CPE)range: < 9.1.0766-r0
- (no CPE)range: < 9.1.0766-r0
- (no CPE)range: < 9.1.0766-r0
- (no CPE)range: < 9.1.0766-r0
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-150500.20.15.1
- (no CPE)range: < 9.1.0836-17.38.1
- (no CPE)range: < 9.1.0836-17.38.1
- (no CPE)range: < 9.1.1101-1.1
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
2- github.com/vim/vim/commit/51b62387be93c65fa56bbabe1c3mitrex_refsource_MISC
- github.com/vim/vim/security/advisories/GHSA-rj48-v4mq-j4vgmitrex_refsource_CONFIRM
News mentions
0No linked articles in our index yet.