VAITP Dataset

← Back to the dataset

CVE-2011-4103

Django Piston 0.2.2.1 and below: Remote code execution via YAML deserialization in emitters.py

  • CVSS 7.5
  • CWE-20 Improper Input Validation
  • Input Validation and Sanitization
  • Local

emitters.py in Django Piston before 0.2.3 and 0.2.x before 0.2.2.1 does not properly deserialize YAML data, which allows remote attackers to execute arbitrary Python code via vectors related to the yaml.load method.

CVSS base score
7.5
Published
2014-10-27
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
Django Piston
Fixed by upgrading
Yes

Solution

Update Django Piston to version 0.2.2.1 or higher.

Vulnerable code sample

import yaml

# Vulnerable loading of YAML data
def vulnerable_load_yaml(yaml_data):
    return yaml.load(yaml_data)

# Example usage
yaml_data = """
- !!python/object/apply:os.system
  args: ["echo vulnerable"]
"""

# This will execute arbitrary code
result = vulnerable_load_yaml(yaml_data)
print(result)

Patched code sample

import yaml

# Safe loading of YAML data
def safe_load_yaml(yaml_data):
    return yaml.safe_load(yaml_data)

# Example usage
yaml_data = """
- !!python/object/apply:os.system
  args: ["echo vulnerable"]
"""

# This will raise an exception or return None instead of executing arbitrary code
try:
    result = safe_load_yaml(yaml_data)
    print(result)
except Exception as e:
    print("Error:", e)

Cite this entry

@misc{vaitp:cve20114103,
  title        = {{Django Piston 0.2.2.1 and below: Remote code execution via YAML deserialization in emitters.py}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2014},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2011-4103},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2011-4103/}}
}

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.