CVE-2024-21520
XSS vulnerability in djangorestframework due to improper input sanitization.
- CVSS 2.1
- CWE-79
- Input Validation and Sanitization
- Remote
Versions of the package djangorestframework before 3.15.2 are vulnerable to Cross-site Scripting (XSS) via the break_long_headers template filter due to improper input sanitization before splitting and joining with <br> tags.
- CWE
- CWE-79
- CVSS base score
- 2.1
- Published
- 2024-06-26
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Input Validation and Sanitization
- Subcategory
- Cross-Site Scripting (XSS)
- Accessibility scope
- Remote
- Impact
- Information Disclosure
- Affected component
- djangorestfr
- Fixed by upgrading
- Yes
Solution
Upgrade to djangorestframework version 3.15.2 or later.
Vulnerable code sample
from django import template
register = template.Library()
@register.filter(is_safe=True)
def break_long_headers(value):
return '<br>'.join(value.splitlines())Patched code sample
from django.utils.html import escape
from django import template
register = template.Library()
@register.filter(is_safe=True)
def break_long_headers(value):
escaped_value = escape(value)
return '<br>'.join(escaped_value.splitlines())Payload
<script>alert('XSS Vulnerability Exploited!');</script>
Cite this entry
@misc{vaitp:cve202421520,
title = {{XSS vulnerability in djangorestframework due to improper input sanitization.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-21520},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-21520/}}
}
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 ::
