GHSA-r5v6-q6j8-8qw2
CVE Information
Arbitrary Code Execution via Shell Keyword Lookup in Vim < 9.2.0839
Date: 23.07.2026 Severity: Medium CVE: requested, not yet assigned CWE: Improper Neutralization of Special Elements used in an OS Command (CWE-78)
Summary
The shell filetype plugins
runtime/ftplugin/sh.vimandruntime/ftplugin/zsh.viminstall a buffer-localkeywordprgthat interpolates its argument into abash -corzsh -ccommand without shell escaping. Because akeywordprgbeginning with:is escaped withfnameescape(), which does not neutralize shell metacharacters, and becauseKin Visual mode passes the whole selection verbatim, a crafted line in a shell script can execute arbitrary commands when the user selects it and pressesK.runtime/ftplugin/ps1.vimis affected in the same way through PowerShell.Description
When a buffer's filetype resolves to bash, zsh or PowerShell, the bundled filetype plugin defines a keyword lookup command and points
keywordprgat it, for example:command! -buffer -nargs=1 ShKeywordPrg silent exe \ ':hor term bash -c "help "<args>" 2>/dev/null || man "<args>""' setlocal keywordprg=:ShKeywordPrgFor a
keywordprgthat starts with:, Vim escapes the argument ofKwithvim_strsave_fnameescape()(src/normal.c), which usesPATH_ESC_CHARS(src/vim.h). That set omits the shell metacharacters;,&,(,)and>; those appear only inSHELL_ESC_CHARS, which is used exclusively for akeywordprgthat is not an Ex command. The filetype plugin adds no escaping of its own, so these characters reach the innerbash -cunchanged and terminate the intended command.In Visual mode,
Kpasses the entire selection rather than the keyword under the cursor, so shell metacharacters are preserved. In Normal mode the argument is restricted to 'iskeyword' characters, which excludes these metacharacters, and the issue does not arise.The same pattern applies to
runtime/ftplugin/zsh.vim, which builds azsh -ccommand, and toruntime/ftplugin/ps1.vim, which passes the argument to PowerShell via-Command.Impact
Arbitrary operating-system command execution in the context of the user running Vim. Exploitation requires:
- Vim with filetype plugins enabled
- the buffer's filetype resolving to sh, bash, zsh or PowerShell
- the victim opening a crafted file, selecting the crafted line in Visual mode and invoking the keyword lookup with
K.The severity is rated Medium because Normal-mode
Kis not affected and exploitation requires the victim to deliberately select the crafted text in Visual mode and invoke the keyword lookup; the bug does not fire on file-open alone.Acknowledgements
The Vim project would like to thank Github user @manus-use for reporting the issue.
References
The issue has been fixed as of Vim patch v9.2.0839.