Cross-Site Scripting Vulnerability in Django - CVE-2015-0220

python-django Updated 02 Oct 2025

Summary

16/01/2015
N/A
Yes i
Unrated
Not published

CVE-2015-0220: The django.util.http.is_safe_url function in Django before 1.4.18, 1.6.x before 1.6.10, and 1.7.x before 1.7.3 does not properly handle leading whitespaces, which allows remote attackers to conduct cross-site scripting (... Affects python-django versions < 1.7.1-1.1. Fixed in 1.7.1-1.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 Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

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, routing, authentication, and templating. However, versions prior to 1.4.18, 1.6.10, and 1.7.3 are vulnerable to a cross-site scripting (XSS) attack due to improper handling of leading whitespaces in URLs.

Vulnerability Detail

The vulnerability arises from the django.util.http.is_safe_url function, which fails to properly sanitize URLs that contain leading whitespaces. This oversight allows attackers to craft malicious URLs, such as those starting with '\njavascript:', which can lead to XSS attacks. If exploited, this vulnerability can allow attackers to execute arbitrary JavaScript in the context of the user's session, potentially compromising sensitive information.

How To Fix

Minimum fixed version

1.7.1-1.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 upgrading is not immediately possible, consider implementing input validation to strip leading whitespaces from URLs before processing them. This can be done by modifying the URL handling logic in your application to include a check that removes any leading whitespace characters.

Conclusion

CVE-2015-0220 is a significant vulnerability in certain versions of Django that can lead to XSS attacks. It is crucial to upgrade to a secure version to mitigate this risk. Additionally, implementing input validation can serve as a temporary workaround until an upgrade can be performed.

See every vulnerability recorded for python-django →

Share this vulnerability

FAQ

CVE-2015-0220 is a vulnerability in Django that allows for cross-site scripting (XSS) attacks due to improper handling of leading whitespaces in URLs.

Django versions before 1.4.18, 1.6.x before 1.6.10, and 1.7.x before 1.7.3 are affected by this vulnerability.

You can use Vulert to monitor and alert for open-source vulnerabilities in your software. Simply upload your manifest file like package-lock.json to check for vulnerabilities.

If exploited, this vulnerability can allow attackers to execute arbitrary JavaScript in the user's browser, potentially leading to data theft or session hijacking.

Yes, you can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Related vulnerabilities

Recent vulnerabilities recorded for python-django.

How To Fix

Minimum fixed version

1.7.1-1.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