CVE-2026-1312: Potential SQL injection via QuerySet.order_by and FilteredRelation
An issue was discovered in 6.0 before 6.0.2, 5.2 before 5.2.11, and 4.2 before 4.2.28.
.QuerySet.orderby() is subject to SQL injection in column aliases containing periods when the same alias is, using a suitably crafted dictionary, with dictionary expansion, used in FilteredRelation. 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 Solomon Kebede for reporting this issue.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/Djangoto a version that resolves this vulnerability.Fixed in 4.2.28 - Upgrade
Upgrade
pip/Djangoto a version that resolves this vulnerability.Fixed in 5.2.11 - Upgrade
Upgrade
pip/Djangoto a version that resolves this vulnerability.Fixed in 6.0.2
Event History
Frequently Asked Questions
What is the severity of CVE-2026-1312?
CVE-2026-1312 is classified as a critical severity vulnerability due to its potential for SQL injection.
How do I fix CVE-2026-1312?
To mitigate CVE-2026-1312, upgrade Django to version 6.0.2, 5.2.11, or 4.2.28 or later.
What versions are affected by CVE-2026-1312?
CVE-2026-1312 affects Django versions prior to 6.0.2, 5.2.11, and 4.2.28.
How does CVE-2026-1312 allow for SQL injection?
CVE-2026-1312 allows SQL injection through the QuerySet.order_by method, specifically with column aliases containing periods.
What types of applications are at risk from CVE-2026-1312?
Applications using vulnerable versions of Django that implement the QuerySet.order_by method are at risk from CVE-2026-1312.