Cloudanix VulnDB

CVE-2011-4140

None

CVSS

—

EPSS

1.1%

Published

Oct 19, 2011

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Track

A flaw in older versions of a web development framework could allow an attacker to trick a user's browser into performing unauthorized actions on their behalf within a vulnerable website.

Chainable
Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Moderate
Impact
Data Tampering
Component
Web Framework
Class
CSRF
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

The vulnerability allows for a bypass of Django's Cross-Site Request Forgery (CSRF) protection mechanism. By manipulating the HTTP Host header, an attacker can cause the application to validate a forged request as legitimate. This allows an attacker to force a victim's browser to perform state-changing actions on the vulnerable application without their consent.

Why it matters to the business

An attacker can trick authenticated users into performing unintended actions, such as modifying or deleting data, changing account settings, or initiating transactions. This can lead to unauthorized account access, data corruption, financial loss, and a significant erosion of user trust in the application. If an administrative user is targeted, the entire application could be compromised.

How an attack unfolds

An attacker first identifies a vulnerable Django application and its domain. They then set up their own domain and create a DNS CNAME record for a subdomain (e.g., `app.attacker.com`) that points to the target application's domain. The attacker crafts a malicious webpage containing JavaScript that sends a request to this CNAME'd subdomain. When a logged-in user of the target application is lured to the attacker's webpage, their browser executes the script. The request is sent to the target application's server, but with a `Host` header of `app.attacker.com`. The vulnerable Django version trusts this header, causing its CSRF check to pass and allowing the malicious request to be processed with the victim's session privileges.

How to fix it

The vulnerability was patched in Django 1.2.8 and 1.3.2. Upgrade all instances of Django to a modern, supported version. As a critical defense-in-depth measure, configure your web application by setting a strict whitelist of allowed hostnames in Django's `ALLOWED_HOSTS` setting. Additionally, configure your web server (e.g., Nginx, Apache) to reject requests with unrecognized Host headers.

How to confirm the fix worked

Confirm that all Django applications have been upgraded to a patched and supported version. To test for exposure, use a tool like `curl` to send a request to the application while specifying a non-whitelisted `Host` header (e.g., `curl -H "Host: example.com" https://your-app-domain.com`). A properly secured application should reject the request, typically with an HTTP 400 Bad Request error, as enforced by the `ALLOWED_HOSTS` setting.

Typical attack path

  1. An attacker identifies a Django application running a version vulnerable to CSRF protection bypass via Host header manipulation.
  2. The attacker configures a DNS CNAME record on a domain they control to point to the vulnerable application's server.
  3. The attacker crafts a malicious webpage with JavaScript designed to submit a forged request to the target application.
  4. The attacker uses social engineering or phishing to trick an authenticated user into visiting the malicious webpage.
  5. The victim's browser executes the script, sending a request to the target application with a manipulated `Host` header.
  6. The application's CSRF protection is bypassed, and the malicious action is executed with the victim's permissions.

How to detect it

Detecting historical exploitation is challenging as successful attacks may appear as legitimate user actions. However, security teams can search for evidence of failed attempts or reconnaissance. Review Django application logs for a high volume of `SuspiciousOperation` errors related to invalid `Host` headers. In web server access logs (e.g., Nginx, Apache), search for requests where the `Host` header does not match the server's expected domain name, especially if the `Referer` header points to an unknown or suspicious external domain.

What your security team should do

  • Immediately prioritize upgrading all Django applications, as versions 1.2 and 1.3 are end-of-life and contain numerous other security vulnerabilities.
  • Audit all Django projects to ensure the `ALLOWED_HOSTS` setting is configured with a strict whitelist of valid domains and not a wildcard.
  • Implement external scanning to identify outdated and potentially vulnerable Django instances across the organization's public-facing assets.

The record

The CSRF protection mechanism in Django through 1.2.7 and 1.3.x through 1.3.1 does not properly handle web-server configurations supporting arbitrary HTTP Host headers, which allows remote attackers to trigger unauthenticated forged requests via vectors involving a DNS CNAME record and a web page containing JavaScript code.

Affected packages

Ecosystem Package Introduced Fixed
PyPI django 0 No fix
PyPI django 0 1.2.7
PyPI django 1.3 No fix
Debian:11 python-django 0 1.3.1-1
Debian:12 python-django 0 1.3.1-1
Debian:13 python-django 0 1.3.1-1
Debian:5.0 python-django 0 1.0.2-1+lenny3
Debian:6.0 python-django 0 1.2.3-3+squeeze2
pypi Django 1.3 No fix

Related vulnerabilities