CVE-2011-4104
Django Tastypie < 0.9.10: Remote code execution via YAML deserialization
- CVSS 7.5
- CWE-20 Improper Input Validation
- Input Validation and Sanitization
- Local
The from_yaml method in serializers.py in Django Tastypie before 0.9.10 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 Tastypie
- Fixed by upgrading
- Yes
Solution
Update Django Tastypie to version 0.9.10 or higher.
Vulnerable code sample
import yaml
from tastypie.serializers import Serializer
class VulnerableYAMLSerializer(Serializer):
def from_yaml(self, content):
# Using yaml.load without a Loader argument is vulnerable
return yaml.load(content) # This is unsafe and can execute arbitrary codePatched code sample
import yaml
from tastypie.serializers import Serializer
class SafeYAMLSerializer(Serializer):
def from_yaml(self, content):
# Use safe_load to prevent execution of arbitrary code
return yaml.safe_load(content)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.
- Safer loading of YAML. Thanks to daveyss for the report! (toastdriven/django-tastypie)
tastypie/serializers.py,tastypie/serializers.py · Serializer.from_yaml
Cite this entry
@misc{vaitp:cve20114104,
title = {{Django Tastypie < 0.9.10: Remote code execution via YAML deserialization}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2014},
note = {VAITP Python Vulnerability Dataset, entry CVE-2011-4104},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2011-4104/}}
}
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 ::
