/

CVE-2026-73077

Severity:

HIGH RISK

(7.8)

OS Command Injection (CWE-78) in Vim Filetype Plugins

CVE-2026-73077

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution

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

Vim's shell-related filetype plugins may pass attacker-controlled Visual-mode selections to keyword help commands without safely separating shell arguments. When a crafted selection is processed by the affected plugins, arbitrary operating-system commands may execute with the privileges of the user running Vim.

Vim's shell-related filetype plugins may pass attacker-controlled Visual-mode selections to keyword help commands without safely separating shell arguments. When a crafted selection is processed by the affected plugins, arbitrary operating-system commands may execute with the privileges of the user running Vim.

Affected context

The issue can occur in Vim installations using the affected shell and scripting-language filetype plugins, including sh.vim, zsh.vim, and ps1.vim. Risk is present when attacker-controlled text is opened or selected in Visual mode and the K command invokes a keyword-help path that ultimately calls Bash, Zsh, or PowerShell without adequate shell-argument separation.

The issue can occur in Vim installations using the affected shell and scripting-language filetype plugins, including sh.vim, zsh.vim, and ps1.vim. Risk is present when attacker-controlled text is opened or selected in Visual mode and the K command invokes a keyword-help path that ultimately calls Bash, Zsh, or PowerShell without adequate shell-argument separation.

Exploit preconditions

  • Attack surface: Vim's Visual-mode keyword-help functionality and related filetype plugins
  • Required access: The victim must open or edit content containing attacker-controlled text
  • Trigger point: Processing a Visual-mode selection with the K command in an affected filetype context
  • Execution context: The command runs with the operating-system privileges of the Vim process
  • Why exploitation is possible: File and path escaping does not reliably neutralize shell metacharacters when selections are incorporated into shell commands
  • Attack surface: Vim's Visual-mode keyword-help functionality and related filetype plugins
  • Required access: The victim must open or edit content containing attacker-controlled text
  • Trigger point: Processing a Visual-mode selection with the K command in an affected filetype context
  • Execution context: The command runs with the operating-system privileges of the Vim process
  • Why exploitation is possible: File and path escaping does not reliably neutralize shell metacharacters when selections are incorporated into shell commands

Why this happens

The underlying bug is insufficient separation between untrusted text and shell command arguments. The affected plugins pass Visual-mode selections through keyword-program command paths that invoke external shells, while escaping mechanisms such as fnameescape() and PATH_ESC_CHARS do not provide complete shell metacharacter protection for this use case. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because attacker-controlled data can influence an operating-system command.

The underlying bug is insufficient separation between untrusted text and shell command arguments. The affected plugins pass Visual-mode selections through keyword-program command paths that invoke external shells, while escaping mechanisms such as fnameescape() and PATH_ESC_CHARS do not provide complete shell metacharacter protection for this use case. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because attacker-controlled data can influence an operating-system command.

Potential impact

  • Arbitrary operating-system commands may execute
  • Files accessible to the Vim user could be read, modified, or deleted
  • User credentials, tokens, or other local data could be exposed
  • The affected workstation or development environment could be compromised
  • Malicious content could cause code or configuration tampering
  • Arbitrary operating-system commands may execute
  • Files accessible to the Vim user could be read, modified, or deleted
  • User credentials, tokens, or other local data could be exposed
  • The affected workstation or development environment could be compromised
  • Malicious content could cause code or configuration tampering

General mitigation guidance

Mitigation generally focuses on preventing untrusted selections from becoming shell syntax or executable command arguments.

Common defensive patterns include:

  • Passing arguments through APIs that preserve argument boundaries rather than constructing shell command strings
  • Avoiding shell interpretation when invoking external tools
  • Applying context-appropriate escaping only where shell execution is unavoidable
  • Restricting or disabling external keyword-program integrations in high-risk editing workflows
  • Running Vim with least-privilege user permissions and limiting access to sensitive files
  • Treating files from untrusted sources as potentially active input during review and editing

Mitigation generally focuses on preventing untrusted selections from becoming shell syntax or executable command arguments.

Common defensive patterns include:

  • Passing arguments through APIs that preserve argument boundaries rather than constructing shell command strings
  • Avoiding shell interpretation when invoking external tools
  • Applying context-appropriate escaping only where shell execution is unavoidable
  • Restricting or disabling external keyword-program integrations in high-risk editing workflows
  • Running Vim with least-privilege user permissions and limiting access to sensitive files
  • Treating files from untrusted sources as potentially active input during review and editing

How teams detect issues like this

Organizations can identify similar weaknesses through:

  • Static analysis for concatenation of user-controlled text into shell commands
  • Code review checks for system(), shell execution, or command-building APIs fed by selections, filenames, or editor buffers
  • Searches for escaping functions used outside their intended context or without argument-boundary preservation
  • Tests that exercise shell metacharacters through editor commands and filetype integrations
  • Policy enforcement requiring safe process-spawning interfaces and explicit restrictions on shell invocation

Automated code review and security scanning tools may help flag command-construction patterns for manual assessment.

Organizations can identify similar weaknesses through:

  • Static analysis for concatenation of user-controlled text into shell commands
  • Code review checks for system(), shell execution, or command-building APIs fed by selections, filenames, or editor buffers
  • Searches for escaping functions used outside their intended context or without argument-boundary preservation
  • Tests that exercise shell metacharacters through editor commands and filetype integrations
  • Policy enforcement requiring safe process-spawning interfaces and explicit restrictions on shell invocation

Automated code review and security scanning tools may help flag command-construction patterns for manual assessment.

Sources

SourceLink
github.comgithub.com/vim/vim/commit/c5a82fe013e73c98004ad7cd4f906b1ad1ed610e
github.comgithub.com/vim/vim/security/advisories/GHSA-r5v6-q6j8-8qw2

Frequently asked

questions

It is generally dependent on a user opening or editing attacker-controlled content and triggering the affected Vim functionality. It does not normally provide a standalone network attack surface.

An attacker typically needs a way to place or supply crafted text that the victim will open in Vim. The resulting commands execute with the victim's local privileges.

Avoid constructing shell command strings from editor selections. Use argument-preserving process APIs, disable unnecessary external command integrations, and apply context-specific validation and escaping.

Treat editor content as untrusted input, review all shell-invocation paths, use least-privilege execution, and enforce static-analysis or policy checks against unsafe command construction.

It is generally dependent on a user opening or editing attacker-controlled content and triggering the affected Vim functionality. It does not normally provide a standalone network attack surface.

An attacker typically needs a way to place or supply crafted text that the victim will open in Vim. The resulting commands execute with the victim's local privileges.

Avoid constructing shell command strings from editor selections. Use argument-preserving process APIs, disable unnecessary external command integrations, and apply context-specific validation and escaping.

Treat editor content as untrusted input, review all shell-invocation paths, use least-privilege execution, and enforce static-analysis or policy checks against unsafe command construction.

Find out what's already
exploitable in your codebase.