/

CVE-2026-52860

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-94) via Vim Python omni-completion

CVE-2026-52860

Modified

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Local Code Execution during Editing Workflow

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 Python omni-completion feature reconstructs and executes function and class definitions from the current buffer using exec(), which allows embedded Python expressions to run at definition time.

When a user triggers omni-completion on a hostile Python buffer, attacker-controlled code in default values, annotations, or base classes can execute with the user's local privileges.

Affected context

This vulnerability arises in Vim installations with Python omni-completion enabled while editing Python source files.

It becomes relevant when users open or interact with untrusted or third-party Python code that may contain crafted function or class definitions.

The issue manifests specifically when omni-completion is triggered, causing Vim to reconstruct and execute definitions from the current buffer as part of building completion candidates.

Exploit preconditions

  • Attack surface: Local editing session within Vim, typically during Python development.
  • Required access: Ability to supply or influence the contents of a Python buffer opened in Vim (e.g., via cloned repositories, shared files, or pasted snippets).
  • Trigger point: User interaction that invokes Python omni-completion, such as completion commands or keybindings tied to omni-complete.
  • Why exploitation is possible: The completion engine reconstructs and executes function and class definitions with exec() in the editor process.

Python evaluates default parameter values, type annotations, and class base expressions at definition time, so attacker-controlled expressions in those positions are executed even though no explicit import statements are used.

Why this happens

The core issue is a code injection pattern where untrusted content from the current buffer is treated as executable Python code during completion.

Vim's Python omni-completion reconstructs function and class definitions and passes them directly to exec() without isolating or constraining the evaluated expressions.

Because Python executes default argument expressions, annotations, and base class expressions when a definition is created, the mere act of reconstructing these definitions triggers execution of attacker-supplied code.

This behavior maps to CWE-94: Improper Control of Generation of Code, where dynamically generated code is built from data that may be influenced by an attacker and executed in a trusted context.

Potential impact

  • Execution of arbitrary Python code under the user's account while editing a malicious buffer.
  • Installation of backdoors or modification of local configuration and project files.
  • Exfiltration or corruption of sensitive files accessible to the user.
  • Alteration of development artifacts, such as source code, virtual environments, or build scripts.
  • Use of the compromised editor session as a pivot to run additional tooling or commands.

General mitigation guidance

Defenses generally focus on avoiding direct execution of buffer-derived code and constraining how completion logic processes untrusted content.

Useful mitigation patterns include:

  • Eliminating or minimizing use of exec() and similar dynamic code evaluation on content derived from editable buffers.
  • Treating source text as data during completion: parse and analyze code structurally rather than re-executing reconstructed definitions.
  • Applying strict sanitization and validation to any dynamically generated code fragments, ensuring they exclude side-effect-bearing expressions.
  • Running completion or analysis logic in a more constrained environment (for example, a separate process or interpreter with reduced capabilities) to limit damage if malicious expressions are encountered.
  • Encouraging users and organizations to treat code from untrusted repositories or shared snippets as potentially hostile, especially when using advanced completion features.

How teams detect issues like this

Detection typically relies on a combination of code inspection and behavioral analysis:

  • Static review of editor and plugin code paths to identify uses of exec(), eval(), or other dynamic execution primitives on buffer content or user-controlled text.
  • Pattern-based checks in code scanners or IDE security linters that flag reconstruction and execution of language constructs taken from documents being edited.
  • Configuration and policy review to identify completion engines or plugins that run interpreters with full user privileges and dynamically execute document content.
  • Monitoring development environments for unexpected interpreter activity originating from editor processes, particularly when triggered by completion or similar UI events.

Automated review tools and SAST rules that highlight dynamic code generation using untrusted inputs can help surface similar issues before release.

Sources

SourceLink
github.comgithub.com/vim/vim/commit/c8c63673bc4253212820626aeeb75999d9a539d2
github.comgithub.com/vim/vim/releases/tag/v9.2.0597
github.comgithub.com/vim/vim/security/advisories/GHSA-52mc-rq6p-rc7c
github.comgithub.com/vim/vim/security/advisories/GHSA-65p9-mwwx-7468
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-52860
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2487987
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-52860.json

Frequently asked

questions

Not directly over the network. Exploitation occurs locally when a user opens and interacts with a malicious Python buffer in Vim and triggers omni-completion, allowing the embedded code to execute within the local editing session.

An attacker must be able to influence the Python source being edited—such as through a cloned repository, downloaded sample code, or shared project file.

Once the victim opens that file in Vim and uses Python omni-completion, the attacker's code can execute under the victim's user account.

The safest approach is to remove or strictly constrain dynamic execution of buffer-derived Python code in the completion logic.

Completion should work by parsing and analyzing code as data rather than reconstructing and executing function or class definitions with exec().

Avoid designing editor or tooling features that execute code originating from documents under edit, especially through generic primitives like exec() or eval().

Treat buffer contents as untrusted input, apply least-privilege principles to any embedded interpreters, and incorporate security-focused code review and automated checks for dynamic code evaluation patterns.

Find out what's already
exploitable in your codebase.