CVE-2019-20807
Vim < 8.1.0881: Arbitrary OS command execution via scripting, bypassing restricted mode
- CVSS 5.3
- CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
- Input Validation and Sanitization
- Local
In Vim before 8.1.0881, users can circumvent the rvim restricted mode and execute arbitrary OS commands via scripting interfaces (e.g., Python, Ruby, or Lua).
- CWE
- CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
- CVSS base score
- 5.3
- Published
- 2020-05-28
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Vim
- Fixed by upgrading
- Yes
Solution
Update Vim to version 8.1.0881 or higher.
Vulnerable code sample
import os
# This function demonstrates the vulnerability by allowing execution of arbitrary OS commands
def execute_command(command):
# Directly executing the command without restriction
return os.system(command)
# Example usage
# This could allow an attacker to execute arbitrary commands
result = execute_command("ls") # Potentially harmful command
print(result)Patched code sample
import vim
# This function is an example of how to restrict access to OS commands
def secure_eval(command):
# Prevent execution of arbitrary OS commands
if 'os.system' in command or 'subprocess' in command:
raise Exception("Execution of OS commands is not allowed in restricted mode.")
return eval(command)
# Example usage
try:
# Attempt to execute a command that could be harmful
result = secure_eval("os.system('ls')")
except Exception as e:
print(e) # Output: Execution of OS commands is not allowed in restricted mode.Cite this entry
@misc{vaitp:cve201920807,
title = {{Vim < 8.1.0881: Arbitrary OS command execution via scripting, bypassing restricted mode}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2019-20807},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-20807/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
