Django Host Header Vulnerability in python-django: Arbitrary URL Generation

python-django Updated 02 Oct 2025

Summary

18/11/2012
N/A
Yes i
Unrated
Not published

CVE-2012-4520: 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. Affects python-django versions < 1.4.2-1. Fixed in 1.4.2-1. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It provides a robust set of features for building web applications, including an ORM, authentication, and URL routing. However, certain versions of Django are vulnerable to a host header attack, which can lead to the generation and display of arbitrary URLs, potentially compromising the security of web applications built on this framework.

Vulnerability Detail

The vulnerability, identified as CVE-2012-4520, affects the django.http.HttpRequest.get_host function in Django versions 1.3.x before 1.3.4 and 1.4.x before 1.4.2. It allows remote attackers to manipulate the Host header values in crafted username and password requests, leading to the generation of arbitrary URLs. This can result in phishing attacks or the exposure of sensitive information, as attackers can control the URL displayed to users.

How To Fix

Minimum fixed version

1.4.2-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If an immediate upgrade is not possible, consider implementing a reverse proxy that sanitizes the Host header before it reaches your Django application. This can help mitigate the risk of arbitrary URL generation while you plan for an upgrade.

Conclusion

The CVE-2012-4520 vulnerability in Django poses significant risks to web applications by allowing attackers to manipulate Host headers. It is crucial to upgrade to a secure version of python-django to protect against these threats. Additionally, utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.

See every vulnerability recorded for python-django →

Share this vulnerability

FAQ

CVE-2012-4520 is a vulnerability in certain versions of Django that allows attackers to generate arbitrary URLs by manipulating the Host header.

Django versions 1.3.x before 1.3.4 and 1.4.x before 1.4.2 are affected by this vulnerability.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. You can check your application against this vulnerability using the Vulert playground without any signup.

The risks include phishing attacks, exposure of sensitive information, and the possibility of users being misled by arbitrary URLs.

Yes, implementing a reverse proxy that sanitizes the Host header can help mitigate the risk until an upgrade can be performed.

Related vulnerabilities

Recent vulnerabilities recorded for python-django.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

1.4.2-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-django

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