CVE-2016-2512: Django - Arbitrary URL Redirection and XSS Vulnerability

django Updated 02 Oct 2025

Summary

08/04/2016
Yes i
Moderate
7.4

CVE-2016-2512: The utils.http.is_safe_url function in Django before 1.8.10 and 1.9.x before 1.9.3 allows remote attackers to redirect users to arbitrary web sites and conduct phishing attacks or possibly conduct cross-site scripting (X... Affects django across 3 version ranges.

< 1.8.10 >= 1.9, < 1.9.3 < c5544d289233f501917e25970c03ed444abbd4f0

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

Also tracked for

The same CVE-2016-2512 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

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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Django is a popular Python web framework that simplifies the development of web applications. It provides various utilities and functions to handle common web development tasks. The 'utils.http.is_safe_url' function in Django versions before 1.8.10 and 1.9.x before 1.9.3 is vulnerable to an arbitrary URL redirection and cross-site scripting (XSS) attack. This function is responsible for validating whether a given URL is safe or not. However, due to a flaw in the implementation, it fails to properly handle URLs containing basic authentication, allowing remote attackers to redirect users to arbitrary websites and potentially conduct phishing attacks or XSS attacks.

Vulnerability Detail

The vulnerability in Django arises from the 'utils.http.is_safe_url' function's inability to correctly validate URLs with basic authentication. Attackers can exploit this by crafting malicious URLs that include basic authentication credentials and tricking users into clicking on them. When a user clicks on the malicious URL, they may be redirected to an attacker-controlled website, leading to potential phishing attacks. Additionally, if the attacker-controlled website contains malicious scripts, it can also result in cross-site scripting (XSS) attacks, compromising the user's sensitive information or performing unauthorized actions on their behalf.

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.

  • < 1.8.10 1.8.10
    pip install --upgrade "django==1.8.10"
  • >= 1.9, < 1.9.3 1.9.3
    pip install --upgrade "django==1.9.3"

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 modifying the 'utils.http.is_safe_url' function to include additional checks for URLs with basic authentication. Here is an example of a possible workaround code snippet:

from django.utils.http import is_safe_url

def safe_url_with_basic_auth(url):
    if '@' in url:
        # Perform additional checks for basic authentication
        # ... (add your custom logic here)
        return False
    return is_safe_url(url)

By implementing this workaround, the function will reject URLs with basic authentication, preventing the vulnerability from being exploited.

Conclusion

The vulnerability in Django versions before 1.8.10 and 1.9.x before 1.9.3 allows remote attackers to perform arbitrary URL redirection and potentially conduct XSS attacks. To mitigate this vulnerability, it is crucial to upgrade Django to the fixed versions or implement the provided workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

The vulnerability allows remote attackers to redirect users to arbitrary websites, potentially leading to phishing attacks. It can also enable cross-site scripting (XSS) attacks, compromising user data and allowing unauthorized actions on their behalf.

The vulnerability affects Django versions before 1.8.10 and 1.9.x before 1.9.3. If you are using an older version, it is recommended to upgrade to a fixed version.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it for any known vulnerabilities, including this one.

While specific exploits targeting this vulnerability may exist, they have not been disclosed publicly. However, it is crucial to address this vulnerability promptly to mitigate the risk of potential attacks.

If upgrading Django is not immediately feasible, you can implement the provided workaround code to mitigate the vulnerability temporarily. However, upgrading to the fixed version is the recommended long-term solution.

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.

  • < 1.8.10 1.8.10
    pip install --upgrade "django==1.8.10"
  • >= 1.9, < 1.9.3 1.9.3
    pip install --upgrade "django==1.9.3"

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