CVE-2020-1171
Visual Studio Code Python extension allows remote code execution by loading configuration files after opening a project
- CVSS 8.8
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Configuration Issues
- Remote
A remote code execution vulnerability exists in Visual Studio Code when the Python extension loads configuration files after opening a project, aka 'Visual Studio Code Python Extension Remote Code Execution Vulnerability'. This CVE ID is unique from CVE-2020-1192.
- CVSS base score
- 8.8
- Published
- 2020-05-21
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Configuration Issues
- Subcategory
- Open Redirects
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Visual Studio Code
- Fixed by upgrading
- Yes
Solution
Update Visual Studio Code Python extension to the latest version.
Vulnerable code sample
import json
def load_config_vulnerable(config_path):
with open(config_path, 'r') as config_file:
# Load the configuration file without validation
config_data = json.load(config_file)
# Potentially dangerous code execution
# Example: Executing arbitrary commands from the config
if 'execute' in config_data:
exec(config_data['execute'])
# Example usage
load_config_vulnerable('path/to/config.json')Patched code sample
import os
import json
def load_config_safe(config_path):
# Ensure the config file is a trusted file
if not os.path.isfile(config_path) or not config_path.endswith('.json'):
raise ValueError("Invalid configuration file.")
with open(config_path, 'r') as config_file:
try:
config_data = json.load(config_file)
# Process the configuration data safely
# Example: Only allow certain keys to be loaded
allowed_keys = {'setting1', 'setting2'}
filtered_config = {key: config_data[key] for key in allowed_keys if key in config_data}
return filtered_config
except json.JSONDecodeError:
raise ValueError("Invalid JSON format in configuration file.")
# Example usage
config = load_config_safe('path/to/config.json')Cite this entry
@misc{vaitp:cve20201171,
title = {{Visual Studio Code Python extension allows remote code execution by loading configuration files after opening a project}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-1171},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-1171/}}
}
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 ::
