CVE-2014-0472
Django <1.4.11, <1.5.6, <1.6.3, and <1.7 beta 2: Remote code execution in reverse function from user input
- CVSS 5.1
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Configuration Issues
- Remote
The django.core.urlresolvers.reverse function in Django before 1.4.11, 1.5.x before 1.5.6, 1.6.x before 1.6.3, and 1.7.x before 1.7 beta 2 allows remote attackers to import and execute arbitrary Python modules by leveraging a view that constructs URLs using user input and a "dotted Python path."
- CVSS base score
- 5.1
- Published
- 2014-04-23
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Configuration Issues
- Subcategory
- Remote File Inclusion (RFI)
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Django
- Fixed by upgrading
- Yes
Solution
Update Django to version 1.4.11 or higher.
Vulnerable code sample
from django.core.urlresolvers import reverse
def vulnerable_reverse(user_input):
# Directly using user input in reverse can lead to arbitrary code execution
return reverse(user_input)Patched code sample
from django.core.urlresolvers import reverse
from django.core.exceptions import ImproperlyConfigured
def safe_reverse(view_name, *args, **kwargs):
# Ensure the view_name is a valid view and not a dotted path
if '.' in view_name:
raise ImproperlyConfigured("Invalid view name: cannot contain '.'")
return reverse(view_name, *args, **kwargs)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.
- [1.5.x] Fixed a remote code execution vulnerabilty in URL reversing. (django/django)
django/core/urlresolvers.py · RegexURLResolver._populate,django/core/urlresolvers.py · RegexURLResolver._reverse_with_prefix,django/core/urlresolvers.py · RegexURLResolver.__init__ - [1.6.x] Fixed a remote code execution vulnerabilty in URL reversing. (django/django)
django/core/urlresolvers.py · RegexURLResolver._reverse_with_prefix - [1.4.x] Fixed a remote code execution vulnerabilty in URL reversing. (django/django)
django/core/urlresolvers.py
Cite this entry
@misc{vaitp:cve20140472,
title = {{Django <1.4.11, <1.5.6, <1.6.3, and <1.7 beta 2: Remote code execution in reverse function from user input}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2014},
note = {VAITP Python Vulnerability Dataset, entry CVE-2014-0472},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2014-0472/}}
}
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 ::
