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.order_by()` 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.
Security readout for executives and security teams
Plain-English summary
CVE-2026-1312 is a high-severity SQL injection risk in Django. A vulnerable application could allow a logged-in attacker to manipulate database queries through a narrow ORM pattern involving order_by(), FilteredRelation, dictionary expansion, and aliases containing periods. Django fixed supported branches in 6.0.2, 5.2.11, and 4.2.28.
Executive priority
Prioritize remediation for internet-facing or multi-user Django systems, especially where authenticated users can influence filtering or sorting. The exploit conditions are narrow, but successful SQL injection can affect data confidentiality, integrity, and availability.
Technical view
Django QuerySet.order_by() can be SQL injectable when a column alias containing periods is reused through a suitably crafted dictionary expansion in FilteredRelation. The CVSS 3.1 score is 8.5, with network attack vector, high complexity, low privileges required, no user interaction, changed scope, and high confidentiality, integrity, and availability impact.
Likely exposure
Exposure is most likely in Django applications running 6.0 before 6.0.2, 5.2 before 5.2.11, or 4.2 before 4.2.28 that use the affected ORM pattern. Unsupported series such as 5.0.x, 4.1.x, and 3.2.x were not evaluated and may also be affected.
Exploitation context
The source bundle does not show KEV listing or confirmed active exploitation. Exploitation appears conditional: the attacker needs low privileges and the application must expose a query path using the specific order_by(), FilteredRelation, alias, and dictionary-expansion pattern.
Researcher notes
Focus review on ORM query construction rather than raw SQL. The key evidence is the vendor-described interaction between QuerySet.order_by(), aliases containing periods, dictionary expansion, and FilteredRelation. Do not assume unsupported Django branches are safe; the source says they were not evaluated.
Mitigation direction
Upgrade Django to 6.0.2, 5.2.11, or 4.2.28 as applicable.
Move unsupported Django branches to a supported fixed release.
Check Red Hat advisories for downstream package availability and status.
Review vendor guidance before applying compensating controls not named in sources.
Validation and detection
Inventory deployed Django versions across application and container images.
Search code for FilteredRelation combined with order_by() and alias dictionaries.
Confirm dependency lockfiles and runtime environments use fixed Django versions.
Check application dependency scanners for CVE-2026-1312 findings.
Review exposed query features requiring authenticated user input.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-89: Database access and collection lookup
Injection into data stores can inform collection, data access, and exfiltration detection reviews. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references database injection or access, so collection and exfiltration review may help. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-89 · source CWE mapping
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.