CVE-2012-4520: Django Django Allows Arbitrary URL Generation Vulnerability

HIGH
Advisory Identifier: GHSA-2655-q453-22f9
CVSS 7.5
CWE-20
Published
Advisory Summary

CVE-2012-4520 is a HIGH (CVSS 7.5) django allows arbitrary url generation vulnerability (CWE-20: Improper Input Validation) affecting Django libraries in the PyPI ecosystem. The issue involves django allows arbitrary url generation. Remediation is available by upgrading affected packages to version 1.3.4, 1.4.2.

CVE-2012-4520 at a Glance

CVE Identifier CVE-2012-4520
GHSA Identifier GHSA-2655-q453-22f9
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-20: Improper Input Validation
Affected Product Django
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/S:U/C:N/I:H/A:N).

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

How to Fix CVE-2012-4520

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: 1.3.4
pip install Django>=1.3.4
Django fixed: 1.4.2
pip install Django>=1.4.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-2012-4520, 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 1.3.4), 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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

The `django.http.HttpRequest.get_host` function in Django 1.3.x before 1.3.4 and 1.4.x before 1.4.2 allows remote attackers to generate and display arbitrary URLs via crafted username and password Host header values.

CVE-2012-4520 Affected Django Versions

2 component(s)
Fixed Versions:
1.3.41.4.2
Product / Package Ecosystem Affected Versions Fixed Version
Django
PyPI
≥ 1.3
< 1.3.4
1.3.4
Django
PyPI
≥ 1.4
< 1.4.2
1.4.2

References

NVD — CVE-2012-4520 NVD
https://nvd.nist.gov/vuln/detail/CVE-2012-4520
Security Fix Commit FIX COMMIT
https://github.com/django/django/commit/92d3430f12171f16f566c9050c40feefb830a4a3
Security Fix Commit FIX COMMIT
https://github.com/django/django/commit/9305c0e12d43c4df999c3301a1f0c742264a657e
Security Fix Commit FIX COMMIT
https://github.com/django/django/commit/b45c377f8f488955e0c7069cad3f3dd21910b071
Django Security Information SECURITY
https://www.openwall.com/lists/oss-security/2012/10/30/4
Django Security Information SECURITY
https://www.djangoproject.com/weblog/2012/oct/17/security
Django Security Information SECURITY
https://www.debian.org/security/2013/dsa-2634
Django Security Information SECURITY
https://web.archive.org/web/20140417023920/http://securitytracker.com/id?1027708
ubuntu.com/usn/usn-1757-1 WEB
https://ubuntu.com/usn/usn-1757-1
ubuntu.com/usn/usn-1632-1 WEB
https://ubuntu.com/usn/usn-1632-1
lists.fedoraproject.org/pipermail/package-a... WEB
https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090970.html
lists.fedoraproject.org/pipermail/package-a... WEB
https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090904.html
lists.fedoraproject.org/pipermail/package-a... WEB
https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090666.html
Django Source Repository REPOSITORY
https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2012-7.yaml
Django Source Repository REPOSITORY
https://github.com/django/django
bugzilla.redhat.com/show_bug.cgi WEB
https://bugzilla.redhat.com/show_bug.cgi?id=865164
bugs.debian.org/cgi-bin/bugreport.c... WEB
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691145
bugs.debian.org/cgi-bin/bugreport.c... WEB
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691145
lists.fedoraproject.org/pipermail/package-a... WEB
http://lists.fedoraproject.org/pipermail/package-announce/2012-October/090666.html
lists.fedoraproject.org/pipermail/package-a... WEB
http://lists.fedoraproject.org/pipermail/package-announce/2012-October/090904.html
lists.fedoraproject.org/pipermail/package-a... WEB
http://lists.fedoraproject.org/pipermail/package-announce/2012-October/090970.html
ubuntu.com/usn/usn-1632-1 WEB
http://ubuntu.com/usn/usn-1632-1
ubuntu.com/usn/usn-1757-1 WEB
http://ubuntu.com/usn/usn-1757-1
Django Security Information SECURITY
http://www.debian.org/security/2013/dsa-2634
Django Security Information SECURITY
http://www.openwall.com/lists/oss-security/2012/10/30/4

Frequently Asked Questions

What is CVE-2012-4520?
CVE-2012-4520 is a security vulnerability in Django involving Django Allows Arbitrary URL Generation under CWE-20: Improper Input Validation.
Which Django versions are affected?
Affected versions include releases prior to 1.3.4, 1.4.2 across affected packages: Django.
What version fixes CVE-2012-4520?
Upgrading to 1.3.4, 1.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Django affected?
Yes, Django is affected in releases prior to 1.3.4, 1.4.2. Upgrade your dependency to 1.3.4, 1.4.2 or later.
What is the CVSS score of CVE-2012-4520?
CVE-2012-4520 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2012-4520?
CVE-2012-4520 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2012-4520?
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-2655-q453-22f9",
  "modified" : "2024-09-18T18:56:00Z",
  "published" : "2022-05-17T05:10:31Z",
  "aliases" : [ "CVE-2012-4520" ],
  "summary" : "Django Allows Arbitrary URL Generation",
  "details" : "The `django.http.HttpRequest.get_host` function in Django 1.3.x before 1.3.4 and 1.4.x before 1.4.2 allows remote attackers to generate and display arbitrary URLs via crafted username and password Host header values.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.3"
      }, {
        "fixed" : "1.3.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.4"
      }, {
        "fixed" : "1.4.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2012-4520"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/92d3430f12171f16f566c9050c40feefb830a4a3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/9305c0e12d43c4df999c3301a1f0c742264a657e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/b45c377f8f488955e0c7069cad3f3dd21910b071"
  }, {
    "type" : "WEB",
    "url" : "https://www.openwall.com/lists/oss-security/2012/10/30/4"
  }, {
    "type" : "WEB",
    "url" : "https://www.djangoproject.com/weblog/2012/oct/17/security"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2013/dsa-2634"
  }, {
    "type" : "WEB",
    "url" : "https://web.archive.org/web/20140417023920/http://securitytracker.com/id?1027708"
  }, {
    "type" : "WEB",
    "url" : "https://ubuntu.com/usn/usn-1757-1"
  }, {
    "type" : "WEB",
    "url" : "https://ubuntu.com/usn/usn-1632-1"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090970.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090904.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/pipermail/package-announce/2012-October/090666.html"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2012-7.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/django/django"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=865164"
  }, {
    "type" : "WEB",
    "url" : "https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691145"
  }, {
    "type" : "WEB",
    "url" : "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=691145"
  }, {
    "type" : "WEB",
    "url" : "http://lists.fedoraproject.org/pipermail/package-announce/2012-October/090666.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.fedoraproject.org/pipermail/package-announce/2012-October/090904.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.fedoraproject.org/pipermail/package-announce/2012-October/090970.html"
  }, {
    "type" : "WEB",
    "url" : "http://ubuntu.com/usn/usn-1632-1"
  }, {
    "type" : "WEB",
    "url" : "http://ubuntu.com/usn/usn-1757-1"
  }, {
    "type" : "WEB",
    "url" : "http://www.debian.org/security/2013/dsa-2634"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2012/10/30/4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-29T22:33:16Z",
    "nvd_published_at" : "2012-11-18T23:55:00Z"
  }
}