Introduction
Attackers can use a single crafted dictionary to compromise the integrity of Django applications that rely on advanced query features. Because Django is popular and the affected version range is broad, this SQL injection risk is present in a wide range of production environments.
Django is a Python web framework with millions of deployments worldwide, including high-traffic sites and critical business systems. Its ORM and query construction features, where this bug sits, are widely used for rapid development and data handling.
Technical information
CVE-2025-57833 is a SQL injection vulnerability in Django's FilteredRelation feature. It is in how Django handles column aliases when code calls QuerySet.annotate() or QuerySet.alias() with Python's dictionary expansion (**kwargs).
The root cause is insufficient validation of the dictionary keys and values used as column aliases. Passing a crafted dictionary through **kwargs can inject malicious input into the SQL query as a column alias. Django's usual SQL injection protections focus on query parameters, not on structural elements like aliases, so this input gets past them.
The vulnerability triggers when user input is used to build the dictionary passed to these methods and FilteredRelation is involved in the query. The injection happens during SQL generation, when the unsanitized alias is written directly into the query string.
No public code snippets are available. The flaw is in the code path that processes column aliases for FilteredRelation when they arrive through dictionary expansion.
Patch information
The Django team's patch for CVE-2025-57833 adds stricter validation of column alias inputs in FilteredRelation. Any dictionary passed to QuerySet.annotate() or QuerySet.alias() now goes through thorough validation, which mitigates the risk of SQL injection attacks.
The patch changes the internal code that handles column aliases within FilteredRelation. It applies strict checks to the structure and content of the supplied dictionaries, which prevents maliciously crafted inputs from compromising the application.
The fix is included in these Django versions:
- Django 5.2.6
- Django 5.1.12
- Django 4.2.24
Developers should upgrade to one of these versions as a priority. Upgrading protects applications against potential SQL injection exploits targeting FilteredRelation column aliases.
Patch source: Django Security Releases 2025-09-03
Affected systems and versions
CVE-2025-57833 affects these Django versions:
- Django 4.2 before 4.2.24
- Django 5.1 before 5.1.12
- Django 5.2 before 5.2.6
An application is at risk if it uses FilteredRelation with QuerySet.annotate() or QuerySet.alias() and accepts user input for dictionary expansion.
Vendor security history
Django has a history of responding to security issues quickly and openly. Earlier vulnerabilities have included SQL injection and denial-of-service flaws, and each was fixed with a timely patch and a clear advisory. The Django Software Foundation runs a mature security process, with regular security releases and a strong focus on secure defaults and best practices.



