CVE-2017-16763
YAML parsing vulnerability in Confire 0.2.0 enables arbitrary Python command execution through "~/.confire.yaml"
- CVSS 9.8
- CWE-91: XML Injection
- Input Validation and Sanitization
- Local
An exploitable vulnerability exists in the YAML parsing functionality in config.py in Confire 0.2.0. Due to the user-specific configuration being loaded from "~/.confire.yaml" using the yaml.load function, a YAML parser can execute arbitrary Python commands resulting in command execution. An attacker can insert Python into loaded YAML to trigger this vulnerability.
- CVSS base score
- 9.8
- Published
- 2017-11-10
- OWASP
- A03 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- PyYAML
- Fixed by upgrading
- Yes
Solution
Update Confire to version 0.2.1 or higher.
Vulnerable code sample
import yaml
def load_config(file_path):
with open(file_path, 'r') as file:
# Using yaml.load which is unsafe and can execute arbitrary code
config = yaml.load(file, Loader=yaml.FullLoader)
return config
config = load_config('~/.confire.yaml')Patched code sample
import yaml
def load_config(file_path):
with open(file_path, 'r') as file:
# Use safe_load instead of load to prevent execution of arbitrary Python code
config = yaml.safe_load(file)
return config
config = load_config('~/.confire.yaml')Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- use safe load instead of load (bbengfort/confire)
confire/config.py · Configuration.load
Cite this entry
@misc{vaitp:cve201716763,
title = {{YAML parsing vulnerability in Confire 0.2.0 enables arbitrary Python command execution through "~/.confire.yaml"}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2017},
note = {VAITP Python Vulnerability Dataset, entry CVE-2017-16763},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2017-16763/}}
}
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 ::
