CVE-2021-32052: Django Header Injection Possible Vulnerability

MODERATE
Advisory Identifier: GHSA-qm57-vhq3-3fwf
CVSS 6.1
CWE-88 CWE-79
Published
Advisory Summary

CVE-2021-32052 is a MODERATE (CVSS 6.1) header injection possible vulnerability (CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')) affecting Django libraries in the PyPI ecosystem. The issue involves header injection possible in django. Remediation is available by upgrading affected packages to version 2.2.22, 3.1.10, 3.2.2.

CVE-2021-32052 at a Glance

CVE Identifier CVE-2021-32052
GHSA Identifier GHSA-qm57-vhq3-3fwf
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
Affected Product Django
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2021-32052

To remediate this vulnerability, upgrade all affected Django dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Django fixed: 2.2.22
pip install Django>=2.2.22
Django fixed: 3.1.10
pip install Django>=3.1.10
Django fixed: 3.2.2
pip install Django>=3.2.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Django

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2021-32052, inspect your installed packages using pip:

pip show Django

Analyze the terminal output to locate any version of Django in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.2.22), your application is affected.

Note: The pip show Django command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection'), where the product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string. In Django, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

In Django 2.2 before 2.2.22, 3.1 before 3.1.10, and 3.2 before 3.2.2 (with Python 3.9.5+), URLValidator does not prohibit newlines and tabs (unless the URLField form field is used). If an application uses values with newlines in an HTTP response, header injection can occur. Django itself is unaffected because HttpResponse prohibits newlines in HTTP headers.

CVE-2021-32052 Affected Django Versions

3 component(s)
Fixed Versions:
2.2.223.1.103.2.2
Product / Package Ecosystem Affected Versions Fixed Version
Django
PyPI
≥ 2.2
< 2.2.22
2.2.22
Django
PyPI
≥ 3.1
< 3.1.10
3.1.10
Django
PyPI
≥ 3.2
< 3.2.2
3.2.2

References

Frequently Asked Questions

What is CVE-2021-32052?
CVE-2021-32052 is a security vulnerability in Django involving Header injection possible in Django under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection').
Which Django versions are affected?
Affected versions include releases prior to 2.2.22, 3.1.10, 3.2.2 across affected packages: Django.
What version fixes CVE-2021-32052?
Upgrading to 2.2.22, 3.1.10, 3.2.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Django affected?
Yes, Django is affected in releases prior to 2.2.22, 3.1.10, 3.2.2. Upgrade your dependency to 2.2.22, 3.1.10, 3.2.2 or later.
What is the CVSS score of CVE-2021-32052?
CVE-2021-32052 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2021-32052?
CVE-2021-32052 is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') (The product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.).
How can I check PyPI dependencies for CVE-2021-32052?
Run the dependency tree command: 'pip show Django'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-qm57-vhq3-3fwf",
  "modified" : "2024-09-20T15:28:25Z",
  "published" : "2021-06-09T17:14:51Z",
  "aliases" : [ "CVE-2021-32052" ],
  "summary" : "Header injection possible in Django",
  "details" : "In Django 2.2 before 2.2.22, 3.1 before 3.1.10, and 3.2 before 3.2.2 (with Python 3.9.5+), URLValidator does not prohibit newlines and tabs (unless the URLField form field is used). If an application uses values with newlines in an HTTP response, header injection can occur. Django itself is unaffected because HttpResponse prohibits newlines in HTTP headers.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.2"
      }, {
        "fixed" : "2.2.22"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.1"
      }, {
        "fixed" : "3.1.10"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.2"
      }, {
        "fixed" : "3.2.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32052"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/e1e81aa1c4427411e3c68facdd761229ffea6f6f"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=1944801"
  }, {
    "type" : "WEB",
    "url" : "https://docs.djangoproject.com/en/3.2/releases/security"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-qm57-vhq3-3fwf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/django/django"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2021-8.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/forum/#!forum/django-announce"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZVKYPHR3TKR2ESWXBPOJEKRO2OSJRZUE"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210611-0002"
  }, {
    "type" : "WEB",
    "url" : "https://www.djangoproject.com/weblog/2021/may/06/security-releases"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2021/05/06/1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-88" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-19T18:12:45Z",
    "nvd_published_at" : "2021-05-06T16:15:00Z"
  }
}