CVE-2015-0221: Django - Denial of Service via Long Line in File
Summary
CVE-2015-0221: The django.views.static.serve view in Django before 1.4.18, 1.6.x before 1.6.10, and 1.7.x before 1.7.3 reads files an entire line at a time, which allows remote attackers to cause a denial of service (memory consumption... Affects django across 3 version ranges.
< 1.4.18
>= 1.5, < 1.6.10
>= 1.7, < 1.7.3
Fixed in 1.4.18, 1.6.10 or 1.7.3, depending on the release line you run. How to fix ↓
Also tracked for
- python-django · Debian:11
The same CVE-2015-0221 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
Django is a popular Python web framework that simplifies the development of web applications. It provides a set of tools and libraries for handling common web development tasks, such as URL routing, database integration, and template rendering. The django.views.static.serve view is responsible for serving static files in Django applications. However, prior to versions 1.4.18, 1.6.x before 1.6.10, and 1.7.x before 1.7.3, this view had a vulnerability that could be exploited to cause a denial of service (DoS) attack.
Vulnerability Detail
The vulnerability (CVE-2015-0221) in Django's django.views.static.serve view arises from the way it reads files. Specifically, it reads files line by line, without any limit on line length. This means that if an attacker provides a file with an excessively long line, it can cause the server to consume excessive memory, leading to a DoS condition. By repeatedly exploiting this vulnerability, an attacker could potentially exhaust the server's memory resources, rendering it unresponsive or causing it to crash.
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.4.181.4.18pip install --upgrade "django==1.4.18" -
>= 1.5, < 1.6.101.6.10pip install --upgrade "django==1.6.10" -
>= 1.7, < 1.7.31.7.3pip install --upgrade "django==1.7.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 updating Django is not immediately feasible, a temporary workaround can be implemented by modifying the django.views.static.serve view to limit the length of lines read from files. Here is an example of how this can be done in the code:
from django.views.static import serve
MAX_LINE_LENGTH = 1024 # Set the maximum line length
def serve_with_line_limit(request, *args, **kwargs):
with open(kwargs['document_root'] + kwargs['path'], 'r') as file:
for line in file:
if len(line) > MAX_LINE_LENGTH:
line = line[:MAX_LINE_LENGTH]
yield line
# Replace the original view with the modified one
django.views.static.serve = serve_with_line_limit
This workaround limits the length of each line read from files to a specified maximum value (e.g., 1024 characters). However, it is important to note that this is only a temporary solution and updating to a patched version of Django is still strongly recommended.
Conclusion
The vulnerability (CVE-2015-0221) in Django's django.views.static.serve view allows remote attackers to cause a denial of service (DoS) condition by providing a file with an excessively long line. To mitigate this vulnerability, it is recommended to update Django to version 1.4.18, 1.6.10, or 1.7.3. If immediate update is not possible, a temporary workaround can be implemented by limiting the length of lines read from files. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for django →
FAQ
The vulnerability allows remote attackers to cause a denial of service (DoS) condition on a Django server by providing a file with an excessively long line. This can lead to memory exhaustion and render the server unresponsive or cause it to crash.
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 the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it for any open-source vulnerabilities, including this one.
Yes, the vulnerability has been fixed in Django versions 1.4.18, 1.6.10, and 1.7.3. It is recommended to update your Django installation to one of these versions to mitigate the risk.
Yes, a temporary workaround is available. By modifying the django.views.static.serve view to limit the length of lines read from files, you can mitigate the risk. However, this is not a permanent solution, and updating Django is still strongly advised.
Related vulnerabilities
Recent vulnerabilities recorded for django.