CVE-2019-12735
vim/neovim: ': source!' command allows arbitrary command execution via modelines
Severity
ImportantRed Hat Product Security
CVSS 3.1
Review impact separately from score.
Published · June 5, 2019
Updated · November 21, 2025
Description
It was found that the :source! command was not restricted by the sandbox mode. If modeline was explicitly enabled, opening a specially crafted text file in vim could result in arbitrary command execution.
Statement
To be successfully and automatically triggered when a specially crafted file is opened, this vulnerability requires 3 parts :
-
The
source!command inability to check if it is running in sandbox mode (the fix commit prevents this) -
The
modelineto be enabled (by default, modeline is disabled when running with root permission. SeeMitigationsteps to disable the modeline) -
A function, to be inserted in the modeline, that can be used to trigger the
source!command (e.g.:assert_fail()in the public reproducer). To the best of our knowledge, no such functions were found in the default installation of Red Hat Enterprise Linux versions 5, 6 and 7 at the time of the flaw. However, Red Hat Enterprise Linux version 8 containsassert_fail().
Without part 2 or 3, it would be required for an attacker to be able to craft the command line used to open the crafted file, in order to trigger the vulnerability.
CVSS score applicability
The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.
Mitigation
The vulnerability can be triggered only if modeline is enabled. You can check whether modeline is enabled within vim via the command :set modeline?
It can be turned off explicitly by adding set nomodeline in a vimrc file.
CVSS / CWE
CVSS 3.1 · 5.3CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L
CWE-94 · Improper Control of Generation of Code ('Code Injection')