CVE-2015-2316
Django versions before 1.6.11, 1.7.7, and 1.8c1 vulnerable to denial-of-service (infinite loop) due to "strip_tags" function with specific Python versions
- CVSS 5.0
- CWE-399
- Resource Management
- Remote
The utils.html.strip_tags function in Django 1.6.x before 1.6.11, 1.7.x before 1.7.7, and 1.8.x before 1.8c1, when using certain versions of Python, allows remote attackers to cause a denial of service (infinite loop) by increasing the length of the input string.
- CWE
- CWE-399
- CVSS base score
- 5.0
- Published
- 2015-03-25
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Django
- Fixed by upgrading
- Yes
Solution
Update Django to version 1.6.11, 1.7.7, or 1.8c1 or higher.
Vulnerable code sample
import re
def vulnerable_strip_tags(value):
while True:
new_value = re.sub(r'<[^>]+>', '', value)
if new_value == value:
break
value = new_value
return valuePatched code sample
import re
def safe_strip_tags(value):
# Limit the number of iterations to prevent infinite loops
max_iterations = 1000
iterations = 0
while iterations < max_iterations:
# Use a regex to remove HTML tags
new_value = re.sub(r'<[^>]+>', '', value)
if new_value == value:
break
value = new_value
iterations += 1
return valuePublished 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.8.x] Fixed an infinite loop possibility in strip_tags(). (django/django)
django/utils/html.py · strip_tags - [1.6.x] Fixed an infinite loop possibility in strip_tags(). (django/django)
django/utils/html.py · strip_tags
Cite this entry
@misc{vaitp:cve20152316,
title = {{Django versions before 1.6.11, 1.7.7, and 1.8c1 vulnerable to denial-of-service (infinite loop) due to "strip_tags" function with specific Python versions}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2015},
note = {VAITP Python Vulnerability Dataset, entry CVE-2015-2316},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2015-2316/}}
}
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 ::
