CVE-2021-32052: Header injection possible in Django

django Updated 02 Oct 2025

Summary

09/06/2021
Yes i
Moderate
6.1

CVE-2021-32052: Header injection possible in Django. Affects django across 3 version ranges.

>= 2.2, < 2.2.22 >= 3.1, < 3.1.10 >= 3.2, < 3.2.2

Fixed in 2.2.22, 3.1.10 or 3.2.2, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-32052 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 Python web framework that provides a set of tools and libraries for building web applications. It is widely used due to its simplicity, scalability, and security features. However, a vulnerability has been discovered in versions 2.2 before 2.2.22, 3.1 before 3.1.10, and 3.2 before 3.2.2 (with Python 3.9.5+), which allows for header injection. This vulnerability can be exploited if an application uses values with newlines in an HTTP response. It is important to note that Django itself is unaffected because HttpResponse prohibits newlines in HTTP headers.

Vulnerability Detail

The vulnerability in Django allows for header injection, which occurs when an attacker is able to inject malicious content into the headers of an HTTP response. This can lead to various security risks, such as cross-site scripting (XSS) attacks, cache poisoning, and session hijacking. The URLValidator in affected versions of Django does not prohibit newlines and tabs, except when the URLField form field is used. This oversight enables an attacker to inject newlines into the headers, potentially allowing them to manipulate the response or inject additional headers.

How To Fix

Latest published version: 6.1.2 as of 22 Oct 2026

pip install --upgrade "django==6.1.2"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

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

  • >= 2.2, < 2.2.22 2.2.22
    pip install --upgrade "django==2.2.22"
  • >= 3.1, < 3.1.10 3.1.10
    pip install --upgrade "django==3.1.10"
  • >= 3.2, < 3.2.2 3.2.2
    pip install --upgrade "django==3.2.2"

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 to the fixed versions is not immediately possible, a temporary workaround can be implemented by manually validating and sanitizing the input values to ensure they do not contain newlines or tabs. This can be done by implementing custom validation logic or using a library that provides secure URL validation. Here is an example of how to sanitize the input using Python's re module:

import re

def sanitize_input(url):
    sanitized_url = re.sub(r'[
	]', '', url)
    return sanitized_url

Conclusion

The header injection vulnerability in Django can have serious security implications, allowing attackers to manipulate HTTP responses and potentially compromise the application. It is crucial to upgrade to the latest patched versions of Django (2.2.22, 3.1.10, or 3.2.2) to mitigate this vulnerability. If immediate upgrading is not possible, implementing a workaround to sanitize input values can provide temporary protection. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

The vulnerability allows for header injection, which can lead to various security risks such as cross-site scripting (XSS) attacks, cache poisoning, and session hijacking.

No, Django itself is unaffected because HttpResponse prohibits newlines in HTTP headers. Only applications that use values with newlines in an HTTP response are vulnerable.

You can use Vulert's playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock and Vulert will analyze it in real-time.

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

You can find more information about this vulnerability, including the CVE identifier and detailed advisory, in the GitHub Advisory Database: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/06/GHSA-qm57-vhq3-3fwf/GHSA-qm57-vhq3-3fwf.json

Related vulnerabilities

Recent vulnerabilities recorded for django.

How To Fix

Latest published version: 6.1.2 as of 22 Oct 2026

pip install --upgrade "django==6.1.2"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

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

  • >= 2.2, < 2.2.22 2.2.22
    pip install --upgrade "django==2.2.22"
  • >= 3.1, < 3.1.10 3.1.10
    pip install --upgrade "django==3.1.10"
  • >= 3.2, < 3.2.2 3.2.2
    pip install --upgrade "django==3.2.2"

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