Skip to content

Ex command injection in Vims NetBeans integration

Moderate
chrisbra published GHSA-mr87-rhgv-7pw6 Apr 7, 2026

Package

Vim (Vim)

Affected versions

<9.2.0316

Patched versions

9.2.0316

Description

Netbeans command injection in Vim < v9.2.0316

Date: 07.04.2026
Severity: Medium
CVE: CVE-2026-39881
CWE: Improper Neutralization of Special Elements used in an OS Command (CWE-78)

Summary

A command injection vulnerability in Vim's netbeans interface allows a malicious
netbeans server to execute arbitrary Ex commands when Vim connects to it, via
unsanitized strings in the defineAnnoType and specialKeys protocol messages.

Description

Vim includes a netbeans interface (:help netbeans) which allows an external
editor server to communicate with Vim over a TCP connection. The interface
handles a defineAnnoType message that defines sign and highlight group names,
and a specialKeys message that defines key mappings.

In defineAnnoType, the typeName, fg, and bg fields are interpolated
directly into Ex commands via coloncmd() without sanitization. Because Vim
interprets | as a command separator in Ex commands, a malicious server can
inject arbitrary Ex commands by embedding |cmd| in any of these fields.

Similarly, in specialKeys, key tokens are passed unsanitized into a map
command string, allowing injection via characters such as | or <.

Exploitation requires:

  • The user starts Vim with the -nb flag pointing to a server controlled by
    the attacker (e.g. vim -nb:localhost:PORT:pwd file).
  • The attacker's server sends a malicious defineAnnoType or specialKeys
    message after the connection handshake.

Impact

Impact is medium. Exploitation requires the user to connect to a malicious
netbeans server, but once connected, arbitrary Ex commands could be executed,
although Vim may output error messages. This can lead to arbitrary file reads
and writes, or further code execution via Ex commands such as :call system().

Acknowledgements

The Vim project would like to thank Github user @Wang1rrr for identifying the
vulnerability.

References

The issue has been fixed as of Vim patch v9.2.0316.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
High
Privileges required
Low
User interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:H/A:N

CVE ID

CVE-2026-39881

Weaknesses

Improper Control of Generation of Code ('Code Injection')

The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. Learn more on MITRE.

Credits