CVE-2025-57833
published 2025-09-03CVE-2025-57833: An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases…
PriorityP265high8.1CVSS 3.1
AVNACHPRNUINSUCHIHAH
EPSS
15.60%
96.4th percentile
An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
Affected
7 ranges
| Vendor | Product | Version range | Fixed in |
|---|---|---|---|
| debian | python-django | < python-django 3:3.2.25-0+deb12u1 (bookworm) | python-django 3:3.2.25-0+deb12u1 (bookworm) |
| djangoproject | django | >= 0 < 4.2.24 | 4.2.24 |
| djangoproject | django | >= 4.2 < 4.2.24 | 4.2.24 |
| djangoproject | django | >= 5.0a1 < 5.1.12 | 5.1.12 |
| djangoproject | django | >= 5.1 < 5.1.12 | 5.1.12 |
| djangoproject | django | >= 5.2 < 5.2.6 | 5.2.6 |
| djangoproject | django | >= 5.2a1 < 5.2.6 | 5.2.6 |
Detection & IOCsextracted from sources · hover to see the quote
command$a$,$b$,$c$,(1)from(select(1)id,(pg_read_file($$/etc/passwd$$))title,(3)author_id,(4)editor_id,(5)number_editor,(6)editor_number,(7)state)filtered_relation_book,(select(1),1↗
- →Look for SQL queries containing PostgreSQL dollar-quoting syntax (e.g., $tag$...$tag$) appearing in Django ORM-generated SQL, particularly within JOIN alias positions or column alias positions, which indicates exploitation of FilteredRelation SQL injection. ↗
- →Monitor Django application logs for SQL queries where user-controlled input appears as column aliases in QuerySet.annotate() or QuerySet.alias() calls, especially containing special characters like `$`, commas, or subquery syntax. ↗
- →The vulnerability stems from an incomplete FORBIDDEN_ALIAS_PATTERN regex in django/db/models/sql/query.py (line 60) that does not block the `$` character; patched versions add `$` to the forbidden pattern. ↗
- ·This SQL injection via FilteredRelation column aliases is only exploitable when user-controlled input is passed (via dictionary expansion **kwargs) directly to QuerySet.annotate() or QuerySet.alias() — applications that do not pass untrusted data as annotation/alias keyword argument names are not affected. ↗
- ·Affected Django versions are 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6; deployments on these versions with PostgreSQL are at heightened risk due to dollar-quoting bypass. ↗
CVSS provenance
nvdv3.18.1HIGHCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
osv8.1HIGH
vendor_debian7.1HIGH
vendor_redhat7.1HIGH
Stop checking back — get the weekly exploitation signal.
Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.
GHSA
Django is subject to SQL injection through its column aliases
ghsa·2025-09-08
CVE-2025-57833 [HIGH] CWE-89 Django is subject to SQL injection through its column aliases
Django is subject to SQL injection through its column aliases
An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
OSV
Django is subject to SQL injection through its column aliases
osv·2025-09-08
CVE-2025-57833 [HIGH] Django is subject to SQL injection through its column aliases
Django is subject to SQL injection through its column aliases
An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
OSV
CVE-2025-57833: An issue was discovered in Django 4
osv·2025-09-03·CVSS 8.1
CVE-2025-57833 [HIGH] CVE-2025-57833: An issue was discovered in Django 4
An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
Red Hat
django: Django SQL injection in FilteredRelation column aliases
vendor_redhat·2025-09-03·CVSS 7.1
CVE-2025-57833 [HIGH] CWE-89 django: Django SQL injection in FilteredRelation column aliases
django: Django SQL injection in FilteredRelation column aliases
An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
An SQL injection flaw has been discovered in the Django web framework. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
Mitigation: Mitigation for this issue is either not available or the currently available options do not meet the Red Hat Product Security criteria comprising ease of use and deployment
Ubuntu
Django vulnerability
vendor_ubuntu·2025-09-03
CVE-2025-57833 Django vulnerability
Title: Django vulnerability
Summary: Django could be SQL injected if it received a suitably
crafted dictionary.
It was discovered that Django incorrectly handled certain inputs.
An attacker could possibly use this issue to perform a SQL injection.
Instructions: In general, a standard system update will make all the necessary changes.
Debian
CVE-2025-57833: python-django - An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 ...
vendor_debian·2025·CVSS 7.1
CVE-2025-57833 [HIGH] CVE-2025-57833: python-django - An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 ...
An issue was discovered in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. FilteredRelation is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed QuerySet.annotate() or QuerySet.alias().
Scope: local
bookworm: resolved (fixed in 3:3.2.25-0+deb12u1)
bullseye: resolved (fixed in 2:2.2.28-1~deb11u8)
forky: resolved (fixed in 3:4.2.24-1)
sid: resolved (fixed in 3:4.2.24-1)
trixie: resolved (fixed in 3:4.2.27-0+deb13u1)
No detection rules found.
No public exploits indexed.
HackerOne
Potential SQL Injection when annotating FilteredRelation on PostgreSQL
hackerone·2025-12-02·CVSS 8.1
CVE-2025-57833 [HIGH] Potential SQL Injection when annotating FilteredRelation on PostgreSQL
Potential SQL Injection when annotating FilteredRelation on PostgreSQL
Hi Django security team !
This vulnerability is related to [CVE 2025-57833](https://docs.djangoproject.com/en/dev/releases/security/#september-3-2025-cve-2025-57833) and [CVE 2025-59681](https://docs.djangoproject.com/en/dev/releases/security/#october-1-2025-cve-2025-59681) as it results from an incomplete Regex filter in the [FORBIDDEN_ALIAS_PATTERN](https://github.com/django/django/blob/4ceaaee7e04b416fc465e838a6ef43ca0ccffafe/django/db/models/sql/query.py#L60).
On PostgreSQL, the `$` symbol can be used to replace quotes and build raw string between tags like this : `$$something$$` or `$tag$something$tag$`. This can be abused to make part of the query interpreted as a raw string instead of the actual query to execu
Bugzilla
CVE-2025-57833 python-django3: Django SQL injection in FilteredRelation column aliases [epel-8]
bugzilla·2025-09-08·CVSS 8.1
CVE-2025-57833 [HIGH] CVE-2025-57833 python-django3: Django SQL injection in FilteredRelation column aliases [epel-8]
CVE-2025-57833 python-django3: Django SQL injection in FilteredRelation column aliases [epel-8]
Disclaimer: Community trackers are created by Red Hat Product Security team on a best effort basis. Package maintainers are required to ascertain if the flaw indeed affects their package, before starting the update process.
The following link provides references to all essential vulnerability management information. If something is wrong or missing, please contact a member of PSIRT.
https://spaces.redhat.com/display/PRODSEC/Vulnerability+Management+-+Essential+Documents+for+Engineering+Teams
Discussion:
Package `python-django3` is retired on the `epel8` dist-git branch (the `dead.package` marker is present); closing as CANTFIX since there's no live package to update.
https://docs.djangoproject.com/en/dev/releases/security/https://groups.google.com/g/django-announcehttps://medium.com/@EyalSec/django-unauthenticated-0-click-rce-and-sql-injection-using-default-configuration-059964f3f898https://www.djangoproject.com/weblog/2025/sep/03/security-releases/http://www.openwall.com/lists/oss-security/2025/09/03/3https://lists.debian.org/debian-lts-announce/2025/09/msg00017.html
2025-09-03
Published