Summary
Vim's netrw plugin can construct executable menu commands from attacker-controlled directory paths without consistently neutralizing command separators or quotes. When a crafted path is browsed or bookmarked in GUI Vim, this may allow arbitrary Ex commands and operating-system commands to run with the user's privileges.
Vim's netrw plugin can construct executable menu commands from attacker-controlled directory paths without consistently neutralizing command separators or quotes. When a crafted path is browsed or bookmarked in GUI Vim, this may allow arbitrary Ex commands and operating-system commands to run with the user's privileges.
Affected context
The issue occurs in GUI Vim environments where the netrw plugin creates Bookmarks, History, or Targets menu entries from directory paths. Risk is present when an attacker can influence a path that is subsequently browsed or bookmarked and the resulting value is interpolated into a :menu command without complete escaping.
The issue occurs in GUI Vim environments where the netrw plugin creates Bookmarks, History, or Targets menu entries from directory paths. Risk is present when an attacker can influence a path that is subsequently browsed or bookmarked and the resulting value is interpolated into a :menu command without complete escaping.
Exploit preconditions
- Attack surface: GUI Vim's netrw menu-generation functionality
- Required access: Ability to cause or place a crafted directory path where it can be browsed or bookmarked
- Trigger point: Construction and execution of netrw Bookmark, History, or Target menu commands
- Why exploitation is possible: Attacker-controlled path data reaches Ex command construction without reliably neutralizing the
|command separator and single-quote characters
- Attack surface: GUI Vim's netrw menu-generation functionality
- Required access: Ability to cause or place a crafted directory path where it can be browsed or bookmarked
- Trigger point: Construction and execution of netrw Bookmark, History, or Target menu commands
- Why exploitation is possible: Attacker-controlled path data reaches Ex command construction without reliably neutralizing the
|command separator and single-quote characters
Why this happens
The vulnerability results from treating filesystem path data as safe command text when dynamically constructing Vim :menu commands. Escaping and filtering logic does not consistently remove or encode command-control characters at several construction sites, allowing path content to alter the intended command stream. This maps primarily to CWE-77: Improper Neutralization of Special Elements used in a Command, with CWE-184: Incomplete List of Disallowed Inputs reflecting gaps in the filtering and neutralization logic.
The vulnerability results from treating filesystem path data as safe command text when dynamically constructing Vim :menu commands. Escaping and filtering logic does not consistently remove or encode command-control characters at several construction sites, allowing path content to alter the intended command stream. This maps primarily to CWE-77: Improper Neutralization of Special Elements used in a Command, with CWE-184: Incomplete List of Disallowed Inputs reflecting gaps in the filtering and neutralization logic.
Potential impact
- An attacker may execute arbitrary Ex commands in the affected Vim process.
- The process may execute operating-system commands with the user's privileges.
- User files, editor settings, or project data could be modified or disclosed.
- The affected workstation may be used as a foothold for further compromise.
- An attacker may execute arbitrary Ex commands in the affected Vim process.
- The process may execute operating-system commands with the user's privileges.
- User files, editor settings, or project data could be modified or disclosed.
- The affected workstation may be used as a foothold for further compromise.
General mitigation guidance
Mitigation focuses on preventing untrusted path data from becoming executable command syntax.
Common defensive patterns include:
- Passing path values through APIs that preserve data as arguments rather than concatenating command strings.
- Applying context-aware escaping for every command-construction site, including menu labels and actions.
- Using strict allowlists for expected path characters where product behavior permits.
- Avoiding dynamic menu generation from untrusted values or isolating such values from executable menu commands.
- Running GUI editor workflows with least privilege and limiting access to sensitive files and operating-system capabilities.
- Applying security-focused regression tests for command separators, quoting characters, and nested path representations.
Mitigation focuses on preventing untrusted path data from becoming executable command syntax.
Common defensive patterns include:
- Passing path values through APIs that preserve data as arguments rather than concatenating command strings.
- Applying context-aware escaping for every command-construction site, including menu labels and actions.
- Using strict allowlists for expected path characters where product behavior permits.
- Avoiding dynamic menu generation from untrusted values or isolating such values from executable menu commands.
- Running GUI editor workflows with least privilege and limiting access to sensitive files and operating-system capabilities.
- Applying security-focused regression tests for command separators, quoting characters, and nested path representations.
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying string concatenation or interpolation into Vim Ex commands, especially :menu commands.
- Code review checks for path, filename, or bookmark values flowing into command execution without context-specific escaping.
- Tests that exercise command separators, quote characters, whitespace, and other metacharacters in directory names.
- Policy enforcement that flags dynamic command construction from filesystem or user-controlled input.
- Runtime monitoring for unexpected child processes or unusual Ex command activity from GUI editor sessions.
- Neutral automated code-review or security-scanning tools that recognize command-injection data flows.
Organizations can look for this class of issue through:
- Static analysis rules identifying string concatenation or interpolation into Vim Ex commands, especially :menu commands.
- Code review checks for path, filename, or bookmark values flowing into command execution without context-specific escaping.
- Tests that exercise command separators, quote characters, whitespace, and other metacharacters in directory names.
- Policy enforcement that flags dynamic command construction from filesystem or user-controlled input.
- Runtime monitoring for unexpected child processes or unusual Ex command activity from GUI editor sessions.
- Neutral automated code-review or security-scanning tools that recognize command-injection data flows.

