CVE-2026-34982
Modeline Sandbox Bypass in Vim Allows Arbitrary Command Execution
Publication date: 2026-04-06
Last updated on: 2026-04-22
Assigner: GitHub, Inc.
Description
Description
CVSS Scores
EPSS Scores
| Probability: | |
| Percentile: |
Meta Information
Affected Vendors & Products
| Vendor | Product | Version / Range |
|---|---|---|
| vim | vim | to 9.2.0276 (exc) |
Helpful Resources
Exploitability
| CWE ID | Description |
|---|---|
| CWE-78 | The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. |
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?
CVE-2026-34982 is a security vulnerability in Vim, an open source command line text editor, affecting versions prior to 9.2.0276. The vulnerability is a modeline sandbox bypass that allows arbitrary operating system command execution when a user opens a specially crafted file.
The root cause is that certain Vim optionsβspecifically 'complete', 'guitabtooltip', and 'printheader'βlack the P_MLE flag, which is necessary for enforcing modeline security checks. Additionally, the mapset() function does not call check_secure(), allowing it to be exploited from sandboxed expressions.
This combination allows attackers to bypass secure mode restrictions and execute arbitrary commands via modelines embedded in files.
How can this vulnerability impact me? :
An attacker who can deliver a crafted file to a victim can exploit this vulnerability to execute arbitrary OS commands with the privileges of the user running Vim.
This can lead to unauthorized actions on the victim's system, including data manipulation or compromise, depending on the permissions of the user.
How can this vulnerability be detected on my network or system? Can you suggest some commands?
This vulnerability can be detected by testing whether Vim executes unsafe modelines that use the `mapset()` function or manipulate the `complete`, `guitabtooltip`, and `printheader` options without proper security flags.
One practical approach is to create a crafted file containing modelines that attempt to exploit the vulnerability, such as using `mapset()` in modelines for these options, and then opening the file in Vim to observe if an error (like E992) is triggered or if arbitrary commands execute.
Specifically, the Vim test added in patch 9.2.0276 (`Test_modeline_forbidden()` in `src/testdir/test_modeline.vim`) writes temporary files with malicious modelines and asserts that opening them fails with error E992, confirming the vulnerability or its fix.
While no direct network detection commands are provided, on the system level, you can check the installed Vim version with the command:
- vim --version | grep 9.2.0276
If the version is older than 9.2.0276, the system is vulnerable. Additionally, scanning files for suspicious modelines containing `mapset()` or the affected options might help detect potential exploit attempts.
How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:
CVE-2026-34982 allows an attacker to execute arbitrary OS commands with the privileges of the user running Vim by exploiting a modeline sandbox bypass. This can lead to unauthorized access or modification of sensitive data.
Such unauthorized command execution and potential data compromise can negatively impact compliance with common standards and regulations like GDPR and HIPAA, which require protection of sensitive data and prevention of unauthorized access.
Specifically, the vulnerability could lead to breaches of confidentiality and integrity of data, which are core concerns in these regulations.
What immediate steps should I take to mitigate this vulnerability?
The immediate and most effective mitigation is to upgrade Vim to version 9.2.0276 or later, where the vulnerability is fixed.
This patch disallows the use of `mapset()` in secure mode and adds the `P_MLE` flag to the `complete`, `guitabtooltip`, and `printheader` options, preventing unsafe modeline evaluation.
Until the upgrade can be applied, avoid opening untrusted or crafted files in Vim, especially those that might contain malicious modelines.
If possible, disable modeline processing in Vim by setting the option `set nomodeline` in your vimrc or command line to reduce exposure.