CVE-2020-13596: Django - XSS Vulnerability in ForeignKeyRawIdWidget

django Updated 02 Oct 2025

Summary

06/03/2024
Yes i
Medium
Not published

CVE-2020-13596: An issue was discovered in Django 2.2 before 2.2.13 and 3.0 before 3.0.7. Affects django across 2 version ranges.

>= 2.2.0, < 2.2.13 >= 3.0.0, < 3.0.7

Fixed in 2.2.13 or 3.0.7, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2020-13596 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Django is a popular open-source web framework written in Python. It provides a set of tools and libraries for building web applications quickly and efficiently. The ForeignKeyRawIdWidget is a widget used in the Django admin interface to display and select foreign key values. This vulnerability affects Django versions 2.2 before 2.2.13 and 3.0 before 3.0.7.

Vulnerability Detail

The vulnerability (CVE-2020-13596) arises from the improper URL encoding of query parameters generated by the Django admin ForeignKeyRawIdWidget. This flaw can be exploited by an attacker to perform a cross-site scripting (XSS) attack. By injecting malicious code into the query parameters, an attacker can execute arbitrary JavaScript code in the context of the victim's browser. This can lead to various security risks, including session hijacking, data theft, and unauthorized actions on behalf of the victim.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 2.2.0, < 2.2.13 2.2.13
  • >= 3.0.0, < 3.0.7 3.0.7

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading Django is not immediately feasible, a temporary workaround can be implemented by manually URL encoding the query parameters generated by the ForeignKeyRawIdWidget. This can be done by modifying the affected code to use the appropriate URL encoding functions provided by the programming language or framework being used. Here is an example in Python:

import urllib.parse

# Generate the URL with properly encoded query parameters
url = 'https://example.com/?param=' + urllib.parse.quote(query_param)

Conclusion

In conclusion, the Django ForeignKeyRawIdWidget vulnerability (CVE-2020-13596) exposes applications to cross-site scripting attacks. It is crucial to upgrade Django to version 2.2.13 or 3.0.7, or apply the provided workaround, to mitigate the risk. Regularly monitoring for vulnerabilities using tools like Vulert can help ensure the security of your applications. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

This vulnerability allows an attacker to execute arbitrary JavaScript code in the victim's browser, potentially leading to session hijacking, data theft, and unauthorized actions on behalf of the victim.

You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Vulert analyzes your package-lock.json file and provides real-time alerts for open-source vulnerabilities.

At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is important to patch your Django installation as soon as possible to mitigate the risk.

While applying the workaround can provide temporary protection, it is strongly recommended to upgrade Django to the fixed versions. Upgrading ensures that you have the latest security patches and improvements, reducing the risk of other vulnerabilities.

You can find more information about this vulnerability in the Django security advisory (https://www.djangoproject.com/weblog/2020/jun/03/security-releases/). It provides detailed information about the vulnerability, its impact, and the fixed versions.

Related vulnerabilities

Recent vulnerabilities recorded for django.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • >= 2.2.0, < 2.2.13 2.2.13
  • >= 3.0.0, < 3.0.7 3.0.7

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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