CVE-2026-53878: Django DomainNameValidator HTTP Header Injection – MEDIUM Severity
Django's domain name validator accepts newlines in domain values, which can lead to HTTP header injection when those values are included in responses. While Django's own `HttpResponse` class protects against this, applications that validate domains with `DomainNameValidator` and then use those values directly in HTTP headers could inadvertently inject malicious headers. The issue affects Django 6.0 before version 6.0.7 and 5.2 before version 5.2.16, though older unsupported versions may also be vulnerable.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 6.1 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Weaknesses (CWE)
- CWE-144
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-07-07 / 2026-07-09
NVD description (verbatim)
An issue was discovered in Django 6.0 before 6.0.7 and 5.2 before 5.2.16. `DomainNameValidator` does not prohibit newlines in domain names (unless used via a form field, since `CharField` strips newlines). If an application uses values with newlines in an HTTP response, header injection can occur. Django itself is unaffected because `HttpResponse` prohibits newlines in HTTP headers. Earlier, unsupported Django series (such as 5.0.x, 4.1.x, and 3.2.x) were not evaluated and may also be affected. Django would like to thank Bence Nagy for reporting this issue.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from `DomainNameValidator` failing to strip or reject newline characters in domain name input. Although `CharField` (used in Django forms) automatically removes newlines, applications bypassing form validation and calling `DomainNameValidator` directly may accept domain values containing CR (\r) or LF (\n) sequences. When these unfiltered values are concatenated into HTTP response headers, they enable header injection—an attacker can inject arbitrary headers by embedding newlines in a domain field. The CVSS score of 6.1 (MEDIUM) reflects network-accessible exploitation with user interaction required (UI:R) and limited confidentiality and integrity impact. CWE-144 (Improper Neutralization of Line Delimiters) accurately categorizes the root cause.
Business impact
The practical risk depends on application architecture. Django applications using `DomainNameValidator` in non-form contexts and directly passing validated domains to HTTP headers face header injection risk, potentially enabling session fixation, cache poisoning, or credential theft. Organizations relying on Django for SaaS platforms, multi-tenant systems, or APIs that expose domain configuration in responses should prioritize assessment. However, the requirement for user interaction and the need for deliberate validator misuse (bypassing form layers) limits the immediate blast radius.
Affected systems
Django 6.0.0 through 6.0.6 and Django 5.2.0 through 5.2.15 are confirmed vulnerable. Django 5.2.16 and 6.0.7 or later are patched. Older unsupported series (5.0.x, 4.1.x, 3.2.x) may be affected but have not been formally evaluated by the Django project. Applications remain vulnerable only if they (1) use `DomainNameValidator` directly outside form contexts, (2) fail to sanitize domain values before including them in HTTP headers, and (3) serve responses to untrusted users who can control domain input.
Exploitability
Exploitation requires user interaction: an attacker must induce a victim to interact with an application that accepts attacker-controlled domain input, validates it with a vulnerable Django version, and reflects that input in an HTTP response header. The attack is not remotely triggerable via passive network observation. However, injection payloads are trivial (a newline followed by header syntax), and many developers may not realize that `DomainNameValidator` alone does not guarantee header-safe output. Real-world exploitation would likely target specific high-value integrations or multi-tenant environments where domain fields are user-configurable.
Remediation
Immediately upgrade to Django 5.2.16 or 6.0.7 (or later versions in each series). Review application code for direct usage of `DomainNameValidator` outside form contexts; if found, add explicit newline stripping or reject domain values containing CR/LF. Consider a defense-in-depth approach: validate domains via forms (which strip newlines), and use Django's `HttpResponse` class or middleware to enforce header sanitization. For unsupported Django versions, apply manual patches equivalent to the official fixes or migrate to a supported series.
Patch guidance
Django 5.2.16 and Django 6.0.7 contain fixes that ensure `DomainNameValidator` rejects newline characters. Consult the official Django security advisory and release notes to verify patch content and any accompanying migration steps. Organizations on unsupported versions (4.1.x, 3.2.x, 5.0.x) should verify the patch logic and consider backporting or immediately planning an upgrade to a supported release. Patches are expected to be backward-compatible; apply them during regular maintenance windows unless an application is known to deliberately rely on newlines in domain validation (highly unlikely).
Detection guidance
Search codebase for direct calls to `DomainNameValidator` outside form field definitions. Use SAST tools to flag domain values used in HTTP header construction. Monitor application logs for anomalous domain values containing escaped newlines or CR/LF sequences. Test validation by submitting domain input with embedded newlines (e.g., `example.com\r\nX-Injected-Header: evil`) and verify that the validator rejects or sanitizes the input. After patching, regression-test to confirm that legitimate domain names still validate correctly.
Why prioritize this
This is a MEDIUM-severity vulnerability with limited but real-world applicability. Prioritize remediation if your Django applications accept user-controlled domain input and reflect that input in HTTP headers, or if you maintain shared validation libraries. For typical Django applications using form-based domain input and Django's standard response handling, the practical risk is low. However, the simplicity of the attack pattern and potential for header injection in edge cases warrant timely patching across all affected versions.
Risk score, explained
CVSS 6.1 reflects a network-accessible attack with low complexity and no privileges required, but mandatory user interaction and limited scope (Client/Server separation via UI requirement). Confidentiality and integrity impacts are both marked as Low because successful header injection typically enables targeted attacks (session fixation, cache manipulation) rather than wholesale system compromise. The score is driven by the ease of exploitation and broad affected user base, tempered by the prerequisite for user involvement and the commonplace availability of defenses (form validation, response sanitization).
Frequently asked questions
Does this affect my Django application if I only use forms to accept domain input?
Likely not. Django's `CharField` (used in form fields) automatically strips newlines, providing an implicit defense. The vulnerability primarily affects code that calls `DomainNameValidator` directly on untrusted input outside the form framework. If you use Django's form layer consistently, your risk is substantially lower, though upgrading is still recommended for defense-in-depth.
Why doesn't Django's HttpResponse protect me automatically?
Django's `HttpResponse` class does prohibit newlines in HTTP headers it sets directly. However, if your application constructs custom headers or uses third-party middleware that doesn't perform equivalent sanitization, or if validated domain values are embedded in header values via string concatenation before being passed to the response, the vulnerability can be exploited. Rely on `DomainNameValidator` to reject invalid input, not on response-layer filtering alone.
Are unsupported Django versions receiving patches?
No. Django 5.0.x, 4.1.x, and 3.2.x are unsupported and will not receive official patches. If you are running unsupported versions, you should plan an upgrade to Django 5.2.16+ or 6.0.7+ immediately. Organizations unable to upgrade should review whether their application uses the vulnerable validator pattern and, if so, implement manual input sanitization as a temporary mitigation.
What should I check in my code to identify if I'm affected?
Search for direct instantiation or calls to `DomainNameValidator` (e.g., `from django.core.validators import DomainNameValidator`). If found outside form definitions, trace whether the validated domain values are used in HTTP headers, cookies, or other header-derived constructs. Also review any custom validators that may accept domain input and perform insufficient newline filtering. If in doubt, run a SAST scan or manual code review focusing on user input → domain validation → HTTP header flow.
This analysis is provided for informational purposes and represents a snapshot of threat intelligence as of the publication date. Actual vulnerability impact, exploitability, and remediation timelines vary based on specific application architecture, deployment configuration, and business context. Organizations should verify all technical details, patch versions, and guidance against official Django security advisories and vendor documentation before taking action. No warranty is made regarding the accuracy or completeness of this intelligence. Always validate findings in your own environment and consult with your security team. Source: NVD (public-domain), retrieved 2026-08-16. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-44545MEDIUMDaphne WebSocket Denial of Service via Unlimited Payload Size
- CVE-2026-53877MEDIUMDjango GIS GDALRaster Buffer Over-Read Vulnerability
- CVE-2026-35193LOWDjango Cache Middleware Leaks Private User Data via Unauthenticated Requests
- CVE-2026-44546LOWDaphne HTTP Header Injection Vulnerability (4.2.2)
- CVE-2026-48587LOWDjango Cache Header Bypass – Whitespace Handling Vulnerability
- CVE-2026-48588LOWDjango Cache Middleware Data Leakage Vulnerability
- CVE-2026-6873LOWDjango Signed Cookie Salt Collision Vulnerability
- CVE-2026-7666LOWDjango SMTP Email Backend STARTTLS Fallback Vulnerability