Skip to main content
Mallory
HighPublic exploitVulnerability

CVE-2026-1312: SQL injection in Django QuerySet.order_by() with FilteredRelation aliases

Published Feb 3, 2026 · Updated 2 months ago
Trending this weekNot trendingOutside this week’s top 100
Mention activity · 30 daysNo mention activity in the last 30 days.
CVSS8.5High · v3.1
EPSS0.90%61st percentile
CISA KEVNoNot listed
In the wildNonePublic exploit, no exploitation reported
Vendor
Djangoproject
IdentifiersCVE-2026-1312CWE-89 · Improper Neutralization of Special…

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.

Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Analyst brief

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.

Public exploits

Exploits

1 exploit validated by Mallory's analysis. Hidden: 1 rejected by Mallory's analysis as not a working exploit.

View more in app →
CVE-2026-1312This repository is a small Django proof-of-concept application built to reproduce CVE-2026-1312, a SQL injection issue in Django ORM query construction. It is not an exploit framework module; it is a standalone demo environment with a vulnerable web endpoint and supporting Docker/devcontainer files. Repository structure: the root contains standard Django project files (manage.py, web/ project config, vuln/ app) plus .devcontainer and VS Code tasking for easy local reproduction. The vuln app defines two models, Author and Book, with seeded sample data in migrations. Routing is minimal: web/urls.py includes vuln.urls under /book/, and vuln/urls.py exposes /book/search. Core exploit logic is in vuln/views.py, specifically Books.get(). The handler reads the attacker-controlled GET parameter 'name', stores it in 'crafted', then uses it directly in Book.objects.alias(**{crafted: relation}).order_by(crafted) with a FilteredRelation('author'). This unsafe pattern allows crafted input containing dotted alias syntax and SQL fragments to influence the generated ORDER BY clause. The README demonstrates a PostgreSQL time-based payload, 'vuln_book.id,pg_sleep(2)', which results in SQL resembling ORDER BY ("vuln_book".id,pg_sleep(2)) ASC. The effect is a delayed response, confirming SQL injection in the ORM-generated query. Capabilities: the code demonstrates remote, unauthenticated SQL injection over HTTP through a query parameter. The included payload is a time-based blind SQLi proof of concept rather than a full post-exploitation chain. No reverse shell, file write, or credential dumping automation is implemented, though the seeded database includes an Author.password field that could be a target for further manual exploitation. Operational details: the app is configured for PostgreSQL, with default containerized database host 'db' and port 5432. The development server listens on 0.0.0.0:8086 and is exposed as localhost:8086. The README provides reproduction steps using VS Code devcontainers and database migrations. Overall, this repository's purpose is to reproduce and validate the vulnerability, not to provide a weaponized exploit toolkit.sw0rd1ight · Disclosed Feb 21, 2026 · python · yaml · networkPoC
Exposure surface

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.

VendorProductType
DjangoprojectDjangoapplication
FAQ

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.
Activity feed

Recent activity

16 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.

View more in app →
+7 more in the timeline. Sign up to see them
Do you run this?See affected versions in your environment and whether adversaries are exploiting this vulnerability against assets like yours.
Check your exposure
Mallory platform

The version that knows your environment.

This page is what’s public. Mallory adds the parts that aren’t: which of your assets are affected, which adversaries are exploiting it right now, and which detections to deploy tonight.
Exposure mappingQuery your assets running an affected version, and investigate the blast radius.
Threat actor evidenceEvery report linking this CVE to a named adversary.
Associated malwareMalware families linked to this CVE, with evidence and IOCs.
Detection signaturesYARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity4Community discussion across Reddit, Mastodon, and other social sources.