CVE-2026-47162 Vim: Vimscript Code Injection in netrw NetrwBookHistSave() via crafted directory name
Attackers can execute arbitrary Vimscript and shell commands by crafting a directory name that exploits improper escaping in the netrw plugin's history saving mechanism.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Over the internet
- Victim action needed
- A user has to click or open something
- Fix
- Available
What is CVE-2026-47162?
CVE-2026-47162 is a high-severity code injection vulnerability in Vim Vim, published on 11 Jun 2026. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Official description
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.
Which versions are affected by CVE-2026-47162?
It affects 1 product.
Products include Vim Vim.
How do I fix CVE-2026-47162?
Upgrade to a fixed version.
Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.
Is CVE-2026-47162 being exploited?
There is no known exploitation of CVE-2026-47162 in the wild and no public exploit code.
Other vulnerabilities in Vim Vim
Sources
Also known as AZL-89778, CLSA-2026-1781535483, CLSA-2026-1781550491, CLSA-2026-1781551234, CLSA-2026-1781552300, CLSA-2026-1781607668 and 8 more.