CVE-2020-25626: Cross-site Scripting (XSS) in Django REST Framework

djangorestframework Updated 02 Oct 2025

Summary

19/03/2021
Yes i
Moderate
6.1

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for djangorestframework.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback