# 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.

- **Severity:** High 7.3 (`CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N`)
- **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:** Yes
- **Published:** 11 Jun 2026
- **Updated:** 18 Sep 2026
- **Also known as:** AZL-89778, CLSA-2026-1781535483, CLSA-2026-1781550491, CLSA-2026-1781551234, CLSA-2026-1781552300, CLSA-2026-1781607668, CLSA-2026-1782138605, CLSA-2026-1782139332, DEBIAN-CVE-2026-47162, ECHO-1d9f-02a2-cd6e, GHSA-crm5-rh6j-2c7c, ROOT-OS-DEBIAN-11-CVE-2026-47162, ROOT-OS-DEBIAN-12-CVE-2026-47162, UBUNTU-CVE-2026-47162

## 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.

Weakness: CWE-140 (Improper Neutralization of Delimiters), CWE-94 (Improper Control of Generation of Code), CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component)

## Which versions are affected by CVE-2026-47162?

It affects 1 product.


Products: Vim Vim.

## How do I fix CVE-2026-47162?

Upgrade to a fixed version.

## 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

- [CVE-2020-20703](https://insights.sbomify.com/CVE-2020-20703/): Memory corruption in n/a (critical 9.8)
- [CVE-2017-6349](https://insights.sbomify.com/CVE-2017-6349/): Integer overflow in n/a (critical 9.8)
- [CVE-2017-6350](https://insights.sbomify.com/CVE-2017-6350/): Integer overflow in n/a (critical 9.8)
- [CVE-2017-5953](https://insights.sbomify.com/CVE-2017-5953/): Integer overflow in n/a (critical 9.8)
- [CVE-2008-3075](https://insights.sbomify.com/CVE-2008-3075/): Command injection in n/a (critical 9.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-47162 and fix it if it is affected.

What it is: 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.
Exploitation: There is no known exploitation of CVE-2026-47162 in the wild and no public exploit code.

Affected product: Vim Vim. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-47162/ (Markdown: https://insights.sbomify.com/CVE-2026-47162/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-47162
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-47162
- OSV: https://osv.dev/vulnerability/CVE-2026-47162

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-47162/
Summaries are generated and may contain mistakes; the official description above is the record.
