CVE-2024-39329 Overview
CVE-2024-39329 is a user enumeration vulnerability in the Django web framework. The flaw resides in the django.contrib.auth.backends.ModelBackend.authenticate() method. Remote attackers can enumerate valid usernames by measuring response times for login requests targeting accounts with unusable passwords. The issue affects Django 5.0 before 5.0.7 and Django 4.2 before 4.2.14. This vulnerability is classified under [CWE-208] Observable Timing Discrepancy. Django maintainers released security fixes on July 9, 2024.
Critical Impact
Attackers can enumerate valid Django user accounts remotely by exploiting timing differences in the authentication backend, enabling targeted credential attacks and reconnaissance.
Affected Products
- Django 5.0 before 5.0.7
- Django 4.2 before 4.2.14
- Applications relying on django.contrib.auth.backends.ModelBackend for authentication
Discovery Timeline
- 2024-07-09 - Django project releases security patches
- 2024-07-10 - CVE-2024-39329 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-39329
Vulnerability Analysis
The vulnerability exists in Django's default authentication backend. When ModelBackend.authenticate() processes a login request, it behaves differently for users with unusable passwords than for users with hashed passwords. Django marks a password as unusable by storing a value that cannot match any password hash, typically set through set_unusable_password().
For accounts with unusable passwords, the backend short-circuits the password verification step. For accounts with valid password hashes, the backend performs a full password hashing comparison, which is computationally expensive. This difference in processing time is measurable over the network.
Remote attackers can send authentication requests for candidate usernames and observe response latency. Fast responses suggest accounts with unusable passwords or nonexistent users, while slower responses indicate accounts with active credentials. This allows attackers to build lists of valid usernames for credential stuffing, password spraying, or targeted phishing campaigns.
Root Cause
The root cause is inconsistent execution time between authentication paths. Django originally implemented a dummy password hash operation to mitigate timing attacks against user enumeration, but the mitigation did not cover the code path for users with unusable passwords. The backend skipped the constant-time hashing routine when it detected the unusable password marker, exposing a timing side channel.
Attack Vector
The attack vector is network-based and requires no authentication or user interaction. An attacker sends repeated POST requests to any endpoint that invokes ModelBackend.authenticate(), such as the Django admin login page or a custom login view. The attacker measures the round-trip time for each request, correlating usernames with response latency to identify accounts with unusable passwords.
The vulnerability manifests in the authenticate() method of django.contrib.auth.backends.ModelBackend. Refer to the Django Weblog Security Updates for the official technical description and patched behavior.
Detect Identity Attacks the Moment Authentication Fails
Singularity™ Identity surfaces credential misuse, lateral movement, and privilege escalation in real time, so you can contain the breach before it spreads.
Stop Identity AttacksDetection Methods for CVE-2024-39329
Indicators of Compromise
- High volume of failed login attempts against /admin/login/ or custom authentication endpoints from a single source or distributed IPs.
- Sequential or dictionary-driven username submissions in web server access logs targeting Django authentication views.
- Anomalous request timing patterns where an attacker sends many logins and appears to measure response latency.
Detection Strategies
- Inspect Django and reverse proxy logs for authentication endpoint abuse, focusing on repeated POST requests with varied usernames and identical malformed passwords.
- Deploy Web Application Firewall (WAF) rules that rate-limit and flag enumeration patterns against django.contrib.auth endpoints.
- Correlate authentication log patterns with downstream credential stuffing or password spraying against enumerated accounts.
Monitoring Recommendations
- Enable structured logging for all authentication attempts, capturing username, source IP, user agent, and response time.
- Monitor response time variance on login endpoints and alert on statistically significant deviations across sequential requests.
- Track failed login rates per source IP and per targeted username to identify enumeration campaigns.
How to Mitigate CVE-2024-39329
Immediate Actions Required
- Upgrade Django to version 5.0.7, 4.2.14, or later immediately.
- Audit application dependencies with pip list or a software bill of materials tool to identify vulnerable Django installations.
- Rotate credentials and enforce multi-factor authentication for administrative accounts that may have been enumerated.
Patch Information
The Django project fixed CVE-2024-39329 in releases 5.0.7 and 4.2.14, published on July 9, 2024. The patch ensures ModelBackend.authenticate() performs constant-time work regardless of whether the target account has a usable password. Review the Django Security Release Notes and the NetApp Security Advisory NTAP-20240808-0005 for downstream product guidance.
Workarounds
- Apply rate limiting on authentication endpoints using django-axes, django-ratelimit, or a reverse proxy to reduce enumeration feasibility.
- Place authentication endpoints behind a WAF or CDN that normalizes response timing and blocks high-frequency login attempts.
- Restrict access to the Django admin login page by IP allowlist or VPN where operationally practical.
# Upgrade Django to a patched release
pip install --upgrade "Django>=4.2.14,<5.0" # for 4.2.x users
pip install --upgrade "Django>=5.0.7" # for 5.0.x users
# Verify installed version
python -m django --version
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

