CVE-2021-44420

7.3 HIGH

📋 TL;DR

This Django vulnerability allows attackers to bypass URL-based access controls by appending trailing newlines to HTTP request URLs. Attackers could access restricted resources that should be protected by path-based authorization rules. All Django applications using affected versions with URL-based access controls are vulnerable.

💻 Affected Systems

Products:
  • Django
Versions: Django 2.2 before 2.2.25, Django 3.1 before 3.1.14, Django 3.2 before 3.2.10
Operating Systems: All operating systems running Django
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects deployments using URL path-based access controls. Applications without such controls or with additional authorization layers may not be vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete bypass of application-level authorization, allowing unauthorized access to sensitive data, administrative interfaces, or protected functionality.

🟠

Likely Case

Partial bypass of access controls leading to unauthorized data exposure or privilege escalation within the application.

🟢

If Mitigated

Limited impact if additional authentication/authorization layers exist beyond URL path checking.

🌐 Internet-Facing: HIGH - Web applications are directly exposed to HTTP requests with crafted URLs.
🏢 Internal Only: MEDIUM - Internal applications could still be exploited by authenticated users or through other attack vectors.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires only HTTP requests with trailing newlines. No authentication needed if target URLs are accessible.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Django 2.2.25, 3.1.14, or 3.2.10

Vendor Advisory: https://www.djangoproject.com/weblog/2021/dec/07/security-releases/

Restart Required: Yes

Instructions:

1. Identify Django version with 'python -m django --version'. 2. Upgrade using pip: 'pip install Django==2.2.25' or 'pip install Django==3.1.14' or 'pip install Django==3.2.10'. 3. Restart all Django processes and web servers.

🔧 Temporary Workarounds

URL Path Sanitization Middleware

all

Add custom middleware to strip trailing newlines from request URLs before processing

Create middleware file with URL sanitization logic and add to MIDDLEWARE setting

Web Server URL Rewriting

linux

Configure web server (nginx/apache) to normalize URLs by removing trailing newlines

nginx: rewrite ^(.*)\n$ $1 permanent;
Apache: RewriteRule ^(.*)\n$ $1 [R=301,L]

🧯 If You Can't Patch

  • Implement additional authorization checks beyond URL path matching
  • Deploy WAF rules to block requests with trailing newlines in URLs

🔍 How to Verify

Check if Vulnerable:

Check Django version and test with HTTP request to protected endpoint with trailing newline (e.g., '/admin/\n')

Check Version:

python -m django --version

Verify Fix Applied:

After upgrade, test that URLs with trailing newlines return 404 or proper authorization response

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests with URLs containing %0A (URL-encoded newline)
  • Access to protected paths from unexpected sources

Network Indicators:

  • HTTP requests with trailing newline characters in URL path

SIEM Query:

url:*/%0A OR url:*\n

🔗 References

📤 Share & Export