VAITP Dataset

← Back to the dataset

CVE-2019-7537

Arbitrary Python command execution in Donfig 0.3.0 via collect_yaml in config_obj.py

  • CVSS 9.8
  • CWE-77 Improper Neutralization of Special Elements used in a Command ('Command Injection')
  • Input Validation and Sanitization
  • Local

An issue was discovered in Donfig 0.3.0. There is a vulnerability in the collect_yaml method in config_obj.py. It can execute arbitrary Python commands, resulting in command execution.

CVSS base score
9.8
Published
2019-03-21
OWASP
A03 Injection
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
Donfig
Fixed by upgrading
Yes

Solution

Update Donfig to version 0.3.1 or higher.

Vulnerable code sample

import yaml

def collect_yaml(yaml_string):
    # This method uses the unsafe loader, which can execute arbitrary code
    return yaml.load(yaml_string, Loader=yaml.FullLoader)

# Example usage
yaml_data = """
key: !!python/object/apply:os.system ['echo vulnerable']
"""
config = collect_yaml(yaml_data)
print(config)

Patched code sample

import yaml

def safe_collect_yaml(yaml_string):
    # Use a safe loader to prevent arbitrary code execution
    return yaml.safe_load(yaml_string)

# Example usage
yaml_data = """
key: value
"""
config = safe_collect_yaml(yaml_data)
print(config)

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.

Cite this entry

@misc{vaitp:cve20197537,
  title        = {{Arbitrary Python command execution in Donfig 0.3.0 via collect_yaml in config_obj.py}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2019-7537},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-7537/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.