CVE-2020-25626: Cross-site Scripting (XSS) in Django REST Framework
Summary
CVE-2020-25626: Cross-site Scripting (XSS) in Django REST Framework. Affects djangorestframework versions < 3.11.2. Fixed in 3.11.2. How to fix ↓
Also tracked for
- djangorestframework · Debian:11
The same CVE-2020-25626 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Django REST Framework is a powerful and flexible toolkit for building Web APIs. It provides a set of tools and libraries for building APIs using Django, a popular Python web framework. The framework allows developers to easily create, test, and debug APIs, making it a popular choice for building web applications. However, versions before 3.12.0 and before 3.11.2 of Django REST Framework are vulnerable to a cross-site scripting (XSS) attack.
Vulnerability Detail
The vulnerability arises when using the browseable API viewer in Django REST Framework. The framework fails to properly escape certain strings that can come from user input. This allows an attacker who can control those strings to inject malicious <script> tags, leading to a cross-site scripting (XSS) vulnerability. An attacker could exploit this vulnerability to execute arbitrary JavaScript code in the context of a victim's browser, potentially stealing sensitive information or performing actions on behalf of the victim.
How To Fix
Latest published version: 3.18.3 as of 22 Oct 2026
pip install --upgrade "djangorestframework==3.18.3"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
3.11.2
This is the first release that contains the fix.
pip install --upgrade "djangorestframework==3.11.2"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the latest version is not immediately feasible, a temporary workaround is to disable the browseable API viewer or implement additional input validation and output encoding to mitigate the risk of XSS attacks. Here is an example of how to disable the browseable API viewer in Django REST Framework:
# settings.py
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
Conclusion
In conclusion, Django REST Framework versions before 3.12.0 and before 3.11.2 are vulnerable to a cross-site scripting (XSS) attack. It is crucial for developers to upgrade to the latest secure version of Django REST Framework or apply the recommended workarounds to mitigate the risk of exploitation. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for djangorestframework →
FAQ
This vulnerability allows an attacker to inject malicious scripts into the web application, potentially leading to the theft of sensitive information or unauthorized actions on behalf of the user.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities in software using Pipfile.lock.
At the time of this advisory, there are no known public exploits specifically targeting this vulnerability. However, it is important to promptly apply the recommended fixes to mitigate the risk of exploitation.
Yes, the CVSS score for this vulnerability is 6.1, indicating a moderate severity level.
You can find more information about this vulnerability in the GitHub Security Advisory at https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/03/GHSA-fx83-3ph3-9j2q/GHSA-fx83-3ph3-9j2q.json
Related vulnerabilities
Recent vulnerabilities recorded for djangorestframework.