JLSEC-2026-1873: Code Injection
Vim is an open source, command line text editor. Prior to version 9.2.0495, a Vimscript code injection vulnerability exists in s:NetrwBookHistSave() in the netrw plugin (runtime/pack/dist/opt/netrw/autoload/netrw.vim) when serializing browsed directory paths to the history file ~/.vim/.netrwhist. A directory name derived from the filesystem is interpolated into a single-quoted Vimscript string literal without escaping embedded single quotes, allowing a crafted directory name to break out of the string context and execute arbitrary Vimscript, including shell commands via system() and :!, the next time the history file is sourced. This issue has been patched in version 9.2.0495.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 9.2.0495
Event History
Frequently Asked Questions
What must an attacker do to trigger this issue?
An attacker needs to cause a user to browse a filesystem directory whose name contains a crafted single quote. The malicious Vimscript is executed later when Vim sources the netrw history file, so user interaction is required.
Who is exposed?
Users of Vim versions before 9.2.0495 who use the netrw plugin and browse attacker-controlled or otherwise untrusted directory names are exposed. The vulnerable history file is ~/.vim/.netrwhist.
What can happen if exploitation succeeds?
The crafted directory name can inject arbitrary Vimscript into the history file. This can include execution of shell commands through system() or :! when the history file is sourced.
What should be done if updating is not immediately possible?
Avoid browsing untrusted directory trees with netrw, particularly locations where another party can create directory names. Removing the affected ~/.vim/.netrwhist file prevents previously serialized malicious entries from being sourced, but it does not prevent new entries from being written.