/

CVE-2026-55895

Severity:

HIGH RISK

(7.8)

Command Injection (CWE-78) in Vim netrw file delete

CVE-2026-55895

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78, CWE-94

Impact:

Arbitrary Code Execution via Editor Commands

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A command injection flaw in Vim's netrw plugin allows crafted filenames to break out of the intended Ex command when deleting files from the directory browser.

By embedding command separators in a filename, an attacker can trigger arbitrary Vimscript execution, which may include shell commands via system() or :!. This becomes risky when users browse and delete files from directories containing attacker-controlled filenames.

Affected context

The vulnerability occurs in Vim's netrw file browser when a user initiates deletion of a local file and the filename is derived from the buffer's directory listing. In affected versions, the filename is interpolated into an Ex command executed via :execute with only backslashes escaped, leaving other metacharacters such as the bar (|) unescaped. When users operate on files in locations where names can be influenced by an attacker (e.g., shared directories, extracted archives, or cloned repositories), the risk of unintended command execution increases.

Exploit preconditions

  • Attack surface: Local use of the Vim netrw plugin while browsing and deleting files.
  • Required access: Ability for an attacker to create or place files with crafted names in a directory that the victim opens with netrw.
  • Trigger point: User invokes a delete operation (e.g., pressing the delete key or the mapped command) on the malicious filename within the netrw file browser.
  • Why exploitation is possible: The filename is concatenated into an Ex command string and passed to :execute with insufficient escaping, allowing the bar (|) character and other command delimiters to terminate the intended command and start a new one, enabling arbitrary Vimscript execution.

Why this happens

The underlying bug is insufficient sanitization of user-controlled data before constructing and executing interpreter commands. In netrw's s:NetrwLocalRmFile() function, filenames originating from the directory listing are embedded directly into an Ex command line. Only backslashes are escaped, leaving other special characters available to alter command structure. This pattern maps to CWE-78: OS Command Injection when Vimscript is used to invoke shell commands, and to CWE-94: Code Injection because the attacker-controlled filename effectively becomes part of the interpreted Vimscript. The insecure design trusts filesystem-derived strings and treats them as safe command arguments without proper quoting or escaping.

Potential impact

  • An attacker may execute arbitrary Vimscript commands in the victim's editor session.
  • An attacker could trigger execution of arbitrary shell commands via :call system() or :!.
  • The victim's local files can be read, modified, or deleted through injected commands.
  • The attacker may gain a foothold for further compromise of the user environment, such as credential theft or data exfiltration.

General mitigation guidance

Mitigation focuses on eliminating interpreter command construction that directly embeds untrusted data. Safer patterns include consistently quoting and escaping all filenames and path strings before passing them to :execute or other command-building APIs, and using structured Vimscript functions that take arguments rather than concatenated command strings. Reducing reliance on shell invocation from within the editor helps limit OS command injection risk. Applying least-privilege principles for the user environment, such as avoiding running editors with elevated privileges, further contains impact if interpreter-level issues occur.

How teams detect issues like this

High-level detection approaches include static analysis or pattern-based searches for :execute calls that build command strings from filenames, buffer names, or other user-controlled sources without comprehensive escaping. Code review should flag any use of concatenated command lines that mix literal commands with variables, particularly where metacharacters (|, ;, !) could alter flow. Security policies can encourage the use of command APIs that accept structured arguments instead of raw strings. Automated review tools or linting plugins can be configured to warn when Vimscript invokes shell commands or constructs dynamic Ex commands from untrusted inputs.

Sources

SourceLink
github.comgithub.com/vim/vim/commit/55bc757a5d436e59d50fe43f7cda94b118f86cb2
github.comgithub.com/vim/vim/releases/tag/v9.2.0663
github.comgithub.com/vim/vim/security/advisories/GHSA-vhh8-v6wx-hjjh

Frequently asked

questions

No. The core issue is arbitrary Vimscript injection, which can run any editor command. Shell command execution is one powerful consequence when injected Vimscript uses :call system() or :! to interact with the operating system.

Not necessarily. The attacker mainly needs the ability to create or control filenames in a directory that the victim later opens with netrw and from which the victim deletes files. Local or remote mechanisms (e.g., archives, repositories, shared folders) that place crafted filenames are sufficient.

Avoid building interpreter or shell command strings by concatenating untrusted data. Instead, apply strict quoting and escaping to all variable parts, or use APIs that separate command logic from parameters so that metacharacters in input cannot change command structure.

Treat any data originating from the filesystem, buffers, or user input as untrusted when constructing commands. During development, enforce code review rules and automated checks to detect dynamic command building, favor argument-based APIs over raw command strings, and minimize integration points that execute shell commands from within the editor environment.

Find out what's already
exploitable in your codebase.