CVE-2026-1312: SQL injection in Django QuerySet.order_by() with FilteredRelation aliases
- Vendor
- Djangoproject
CVE-2026-1312 is a SQL injection vulnerability in Django's QuerySet.order_by() handling of column aliases containing periods. The vulnerability occurs when the same alias is used in FilteredRelation through a suitably crafted dictionary passed using dictionary expansion. Affected releases include Django 6.0 before 6.0.2, 5.2 before 5.2.11, and 4.2 before 4.2.28. Earlier unsupported series, including 5.0.x, 4.1.x, and 3.2.x, were not evaluated and may also be affected. Successful exploitation can manipulate database queries, with potential unauthorized data access or modification depending on application context.
Impact, mitigation & remediation
What it means and what to do now: patch path, interim mitigations, and the assume-compromise checklist.
Impact
What an attacker gets, and what they’ve been doing with it.
Successful exploitation permits SQL injection into database queries generated through the affected ORM pattern. Potential consequences include unauthorized query manipulation, database data access, and data modification. The extent of database-level impact depends on the application's query context and database permissions; specific availability impacts are not established.
Mitigation
If you can’t patch tonight, do this now.
No definitive workaround is documented. Until patching is possible, review and restrict unsafe use of period-containing column aliases in QuerySet.order_by() combined with FilteredRelation and dictionary expansion. Validate untrusted input before its use in these query constructions, restrict access to affected application endpoints, and monitor for anomalous SQL injection attempts. These measures reduce exposure but do not replace the security update.
Remediation
Patch, then assume compromise.
Upgrade to Django 6.0.2 or later in the 6.0 series, 5.2.11 or later in the 5.2 series, or 4.2.28 or later in the 4.2 series. Deployments on unsupported upstream series should migrate to a supported, patched release or install an applicable vendor-supported security update. Debian provides fixed python-django packages 3:3.2.25-0+deb12u2 for bookworm and 3:4.2.28-0+deb13u1 for trixie. For affected Red Hat deployments, apply RHSA-2026:3958 or RHSA-2026:3959 for Ansible Automation Platform, or RHSA-2026:5970 or RHSA-2026:5971 for Satellite, as applicable.
Exploits
1 exploit validated by Mallory's analysis. Hidden: 1 rejected by Mallory's analysis as not a working exploit.
Affected products & vendors
Products and vendors Mallory has correlated with this vulnerability. Open in Mallory to drill down to specific CPE configurations and version ranges.
References
Frequently asked questions
- Is CVE-2026-1312 exploited in the wild?
- As of Oct 3, 2026, Mallory has no reports of CVE-2026-1312 being exploited in the wild. It is not listed in CISA KEV.
- Is there a public exploit for CVE-2026-1312?
- Yes. Mallory tracks 1 public exploit or proof of concept for CVE-2026-1312, the earliest disclosed Feb 21, 2026.
- Is there a patch for CVE-2026-1312?
- Upgrade to Django 6.0.2 or later in the 6.0 series, 5.2.11 or later in the 5.2 series, or 4.2.28 or later in the 4.2 series. Deployments on unsupported upstream series should migrate to a supported, patched release or install an applicable vendor-supported security update.
- What products are affected by CVE-2026-1312?
- Djangoproject Django.
- How severe is CVE-2026-1312?
- CVE-2026-1312 has a CVSS v3.1 score of 8.5 (High) and an EPSS score of 0.90% (61st percentile) as of Oct 3, 2026.
Recent activity
16 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.