Introduction
Under specific query conditions, the Django ORM could bind query parameters to the wrong SQL placeholders when building range and in lookups, which opens a path to SQL injection inside the framework's own query construction layer. Because the bug lives in the ORM rather than in any single application, every project on an affected release inherits it. The CVE record scores it 9.8 Critical under CVSS 3.1 and 9.3 Critical under CVSS 4.0, and Django rates it high severity.
This post is a brief summary of CVE-2026-132092 based on the Django advisory, the CVE record and the upstream fix commits.
Technical information
Severity and classification
- Weakness: CWE 89, SQL Injection
- CVSS 3.1: 9.8 Critical, vector
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - CVSS 4.0: 9.3 Critical
- Django rating: high
The vector describes a network-reachable flaw with low attack complexity, no privileges and no user interaction required, and high impact to confidentiality, integrity and availability. It is severity metadata only. The CVE record does not include a working proof of concept or reproduction steps.
Root cause: placeholders and parameters falling out of step
The Django ORM builds SQL strings containing %s placeholders and sends the values separately as a parameter list. That model is only safe while the number of placeholders equals the number of parameters.
If a column alias or JSON key transform contains a percent sign, for example x%sy, it adds an extra %s to the SQL text. Any lookup in the same query that also produces too many or too few parameters can then shift the parameter binding. A regression test added with the fix states plainly that "unbalanced placeholders and parameters could lead to SQL injection."
Two lookups could reach that unbalanced state.
__range
Range.get_rhs_op() read only the first two right-hand-side values and silently ignored any others:
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup): def get_rhs_op(self, connection, rhs): return "BETWEEN %s AND %s" % (rhs[0], rhs[1])
If a caller passed three or more values, only two placeholders were rendered into the SQL text, but every value was still appended to the parameter list. The result was surplus parameters, which the stray %s contributed by a percent-sign alias could absorb.
__in with a bilateral transform
batch_process_rhs() paired compiled SQL fragments with their parameters using Python's default zip():
sql, params = zip( *( self.resolve_expression_parameter(compiler, connection, sql, param) for sql, param in zip(*pre_processed) ) )
A bilateral transform can compile None into IS NULL, which carries no parameter, so the fragment and parameter sequences can end up with different lengths. Default zip() silently truncates to the shorter input, so the mismatch was never surfaced.
Attack flow
Based on the advisory and the regression tests, the vulnerable condition comes together as follows:
- A query includes a column alias or a key transform whose name contains a percent sign, such as
x%sy. This places an additional%sin the generated SQL text. - The same query uses either
__rangewith more than two right-hand-side values, or__inover a bilateral transform where the value list includesNoneand the list is batched (the test forcesmax_in_list_sizeto 2). - The lookup emits a parameter count that no longer matches its own placeholders, and the extra
%sfrom the alias picks up a value that was meant for a different position. - Because the database driver now binds values to unintended placeholders, the structure of the executed query no longer matches what the ORM intended, which is the SQL injection condition the fix addresses.
The available records do not identify a specific application endpoint or describe how untrusted input reaches these conditions in a particular deployment. Teams assessing exposure should look at where their code builds aliases or key transforms dynamically and where range or in lookups receive caller-controlled value lists.
Patch information
Django fixed the issue in Django 6.1.4, 6.0.11 and 5.2.20, released December 2, 2026. The upstream fix is commit 1eb6104c on main, titled "Fixed CVE-2026-132092 -- Prevented SQL injection via Range and In lookups." Sarah Boyce wrote it with Jacob Walls as coauthor, and Simon Charette reviewed it. The 5.2.x backport is 5a8963c9. The upstream patch check output also lists e0e78769 for 6.1.x and da230e17 for 6.0.x.
The code change
The fix touches only three lines in django/db/models/lookups.py, and each change turns a silent mismatch into an error.
In batch_process_rhs(), the inner zip() becomes strict:
sql, params = zip( *( self.resolve_expression_parameter(compiler, connection, sql, param) for sql, param in zip(*pre_processed, strict=True) ) )
In Range, the right-hand side is unpacked instead of indexed:
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup): def get_rhs_op(self, connection, rhs): start, end = rhs return "BETWEEN %s AND %s" % (start, end)
start, end = rhsuses tuple unpacking, which raisesValueErrorunless there are exactly two values. The query now fails before any SQL is built. The release notes state: "Therangelookup now requires exactly two right-hand side values."zip(..., strict=True)(Python 3.10+) raisesValueErrorwhen the SQL fragments and parameter lists differ in length, so__incan no longer bind parameters to the wrong placeholders.
What the regression tests check
test_range_lookup_requires_exactly_two_valuesasserts thatArticle.objects.filter(headline__range=["a", "b", "c"])raisesValueErrorwhen evaluated. Onmain, a second test does the same with an annotated alias namedx%sy.test_values_expression_alias_bilateral_transform_nullregisters a bilateralLowertransform and runsname__lower__in=[None, "this", "that"]withmax_in_list_sizeforced to 2, combined with avalues("data__missing")key transform. The test comment acknowledges this query should work, but it now raisesValueErrorbecausestrict=Trueblocks the surplus parameter.
Django chose to fail closed. In practice, a small number of legitimate but unusual __in queries that combine bilateral transforms with None may now raise errors instead of returning rows, and any code passing more than two values to range will now fail loudly.
Related hardening and what remains
Aliases and key transforms can still contain percent signs after the patch. What it removes are the two ways those stray placeholders could be exploited. Per the release notes, percent signs in column aliases and key transforms were already deprecated in Django 6.0, with removal scheduled for "Django 2028". On main, the commit adds a test confirming that values("data__x%sy") raises a RemovedInDjango2028Warning, and it leaves a commented-out "x%sy" entry in the alias injection test list, to be enabled once such aliases are rejected outright. The 5.2.x backport carries the same lookups.py changes and core regression tests, but not the tests tied to the 6.0 deprecation.
Affected systems and versions
- Django 6.1: versions before 6.1.4 are affected, fixed in 6.1.4
- Django 6.0: versions before 6.0.11 are affected, fixed in 6.0.11
- Django 5.2: versions before 5.2.20 are affected, fixed in 5.2.20
- Unsupported series (such as 5.1.x, 5.0.x and 4.2.x): not evaluated by Django and may also be affected. The advisory lists no fixed releases for them.
The vulnerable configuration is a query that involves an alias or key transform containing a percent sign together with a range lookup receiving more than two values, or an in lookup over a bilateral transform whose values include None and are batched.
Django encourages all users to upgrade as soon as possible, and the sources reviewed describe no workaround other than upgrading.
Vendor security history
Django is maintained with support from the Django Software Foundation. Its security team handles private reports and security policy, and Django Fellows, Foundation-funded contractors, manage releases and help resolve security issues. The project keeps a public archive of security issues, which notes that versions outside security support may have been affected without appearing in the supported version lists. In this case Django shipped coordinated fixes across the 5.2, 6.0 and 6.1 branches with regression tests. Earlier in 2026 the security team wrote publicly that many reports are variants of known issue patterns, and that it weighs consistent handling against the disruption security releases cause for users and maintainers. Django credits Cristian Panaro with reporting this issue.
References
- NVD entry for CVE-2026-132092
- CVE Record: CVE-2026-132092
- Django security releases issued: 6.1.4, 6.0.11, and 5.2.20
- Django security release archive (dev)
- Django archive of security issues (6.1)
- django announce mailing list
- Fix commit 1eb6104c on main
- Fix commit 1eb6104c (GitHub API)
- Backport commit 5a8963c9 for 5.2.x
- Backport commit 5a8963c9 (GitHub API)
- Commit e0e78769 for 6.1.x
- Commit da230e17 for 6.0.x
- Recent trends in the work of the Django Security Team
- Django Software Foundation teams
- Django project homepage
- Stack Overflow Developer Survey 2026: web frameworks



