Skip to main content
Mallory
HighPublic exploitVulnerability

CVE-2025-57833: SQL injection in Django FilteredRelation column aliases

Published Sep 3, 2025 · 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.1High · v3.1
EPSS27.1%98th percentile
CISA KEVNoNot listed
In the wildNonePublic exploit, no exploitation reported
Vendor
Djangoproject
IdentifiersCVE-2025-57833CWE-89 · Improper Neutralization of Special…

CVE-2025-57833 is an SQL injection vulnerability in Django affecting FilteredRelation handling in Django 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. The flaw occurs when a suitably crafted dictionary is expanded as **kwargs into QuerySet.annotate() or QuerySet.alias(), allowing attacker-influenced column alias data associated with FilteredRelation to be incorporated into generated SQL without sufficient validation. The issue affects structural SQL elements such as aliases rather than ordinary query parameters, which allows the vulnerability to bypass Django’s usual parameterization protections in the vulnerable code path.

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 allows SQL injection in affected Django applications. Impact depends on the application’s query construction and the privileges of the database account used by Django, but can include unauthorized query manipulation, disclosure of sensitive data, modification of application data, bypass of application logic enforced through ORM queries, and potentially more severe database-level effects where the backend and privileges permit dangerous SQL capabilities.

Mitigation

If you can’t patch tonight, do this now.

No broadly accepted vendor mitigation is available short of patching. Where immediate upgrade is not possible, reduce exposure by eliminating or tightly constraining dynamic alias construction, forbidding untrusted input from influencing dictionary keys expanded into QuerySet.annotate() or QuerySet.alias(), and using strict allowlists for any user-selectable alias or field metadata. Additional compensating controls such as query anomaly monitoring, least-privilege database accounts, and request filtering may reduce impact but do not fully remediate the vulnerability.

Remediation

Patch, then assume compromise.

Upgrade Django to a fixed supported release: 4.2.24 or later on the 4.2 branch, 5.1.12 or later on the 5.1 branch, or 5.2.6 or later on the 5.2 branch. Apply vendor security errata for downstream packaged products that embed vulnerable Django versions. After upgrading, review application code that dynamically constructs dictionaries passed via **kwargs to QuerySet.annotate() or QuerySet.alias(), especially where FilteredRelation is used, to ensure alias names cannot be influenced by untrusted input.

Public exploits

Exploits

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

View more in app →
CVE-2025-57833This repository is a comprehensive, intentionally vulnerable testbed for CVE-2025-57833, a critical SQL injection vulnerability in Django's ORM when using FilteredRelation with user-controlled field names. The structure includes a full Dockerized environment (Dockerfile, docker-compose), a Django web application (vuln_app), and multiple exploit and test scripts (local_attacks/exploit.py, exploit_test.py, test_sqli.py, run_test.py). The main exploit vector is the /api/vulnerable-search/ endpoint, which passes user input directly as a field name to FilteredRelation and select_related, allowing arbitrary SQL injection. The repository demonstrates both information disclosure and remote code execution (RCE) on PostgreSQL via COPY TO PROGRAM. It includes both vulnerable and safe code examples, automated exploit scripts, and extensive documentation for educational and research purposes. The exploit is operational, providing working payloads and automation for testing the vulnerability, and is not part of a larger exploit framework.Mkway · Disclosed Sep 5, 2025 · python · sql · networkOperationalCVE-2025-57833This repository contains a Django web application (cve_2025_57833) and a corresponding exploit script (exploit.py) targeting a SQL injection vulnerability in the /api/search/ endpoint. The Django app is structured with standard project and app directories, including models for 'Author' and 'Book', migrations, views, and templates. The main vulnerability lies in the 'search' view, which allows user-controlled input to be used as a key in a dynamic annotation and filter, leading to a SQL injection vector when untrusted input is supplied in the 'search_field' parameter. The exploit.py script automates exploitation by sending a crafted payload to the /api/search/ endpoint. The payload abuses PostgreSQL's COPY TO PROGRAM feature to execute arbitrary shell commands on the server, specifically spawning a reverse shell back to the attacker's machine (localhost:8888 by default). The exploit demonstrates remote code execution via SQL injection, making it operational and dangerous if the target is misconfigured or exposed. Key endpoints include the vulnerable /api/search/ HTTP endpoint, the use of /tmp/f as a FIFO for the reverse shell, and the attacker's listener at localhost:8888. The repository is a functional proof-of-concept for CVE-2025-57833, demonstrating a real-world SQL injection to RCE chain in a Django/PostgreSQL environment.Gayang2902 · Disclosed Nov 27, 2025 · python · html · networkOperationalCVE-2025-64459This repository is not a standalone exploit against a remote third-party target; it is an intentionally vulnerable Django/PostgreSQL lab application designed to demonstrate and exercise a family of Django ORM SQL injection and query-manipulation issues. The core logic is in app/vulnapp/views.py, where multiple HTTP GET parameters are passed directly into ORM constructs that expect SQL identifiers or special keyword arguments rather than safely parameterized values. The app exposes separate routes for each candidate sink, including order_by(), annotate alias expansion, Trunc/Extract kind selection, values()/values_list() field selection, JSONField key transforms, explain() option names, FilteredRelation aliasing, dates()/datetimes() kind, distinct(*fields), in_bulk(field_name=), and unsafe filter(**request.GET.dict()) handling. Repository structure is compact: Dockerfile and docker-compose.yml build a reproducible environment with Django 3.2.4 and PostgreSQL; entrypoint.sh performs migrations, seeds the database, and launches the server; app/vulnapp/models.py defines Category and Person models; app/vulnapp/management/commands/seed.py populates sample records and creates a default admin user; app/vulnproj/urls.py maps the vulnerable routes; and app/vulnproj/settings.py configures PostgreSQL connectivity and permissive ALLOWED_HOSTS. The seeded data and JSON responses are intentionally designed to provide row content and differential behavior useful for testing boolean/error-based or data-extraction-oriented SQLi techniques. Main exploit capabilities provided by the application include: exposing multiple web-reachable SQLi-like primitives in Django ORM identifier contexts; enabling response-based calibration through returned rows and counts; demonstrating access-control impact via the /scoped/ endpoint where attacker-controlled _connector can weaken a pinned filter; and supporting extraction experiments via /list/ where a plain listing avoids count()-related column-count constraints. Because the repository is a vulnerable target/lab rather than a packaged offensive exploit script, there is no embedded shell payload or callback infrastructure, but it is clearly exploit-oriented and operational as a testbed for HTTP-based exploitation of the listed CVEs and related patterns.YouGina · Disclosed Aug 11, 2026 · python · shell · web · networkOperationalDjango-faille-CVE-2025-57833_testThis repository is a Django project demonstrating a proof-of-concept exploit for CVE-2025-57833, a SQL injection vulnerability in Django prior to version 4.2.23. The vulnerability arises when user-controlled data is used as dynamic aliases in annotate() or alias() calls, and is further exacerbated by the use of Python's eval() on user input. The main exploit is implemented in 'myapp/views.py' in the 'vulnerable_view' function, which accepts a JSON dictionary via the 'alias' GET parameter, evaluates its values, and uses them as dynamic annotations. This allows an attacker to inject arbitrary SQL or execute Python code. The vulnerable endpoint is exposed at '/vuln/' as defined in 'myproject/urls.py'. The repository includes standard Django project files, application code, and a virtual environment. The exploit is a POC and not weaponized, but demonstrates the risk of unfiltered user input in ORM annotations. The README provides detailed context, exploitation steps, and mitigation advice.loic-houchi · Disclosed Sep 9, 2025 · python · networkPoCCVE-2025-57833This repository is a proof-of-concept (PoC) vulnerable Django application designed to demonstrate CVE-2025-57833, a SQL injection vulnerability in Django versions 4.2 before 4.2.24, 5.1 before 5.1.12, and 5.2 before 5.2.6. The application consists of a simple book/author model and exposes a vulnerable endpoint at /vuln/ (see vulnproj/books/views.py and vulnproj/vulnproj/urls.py). The vulnerability is present in the 'vuln_view' function, where user input from the 'param' GET parameter is unsafely passed as a keyword argument to the QuerySet.alias() method, leading to potential SQL injection. The exploit.sh script demonstrates exploitation by sending a crafted HTTP request to the vulnerable endpoint. The repository includes Dockerfile and seed data for easy setup. The main exploit capability is remote SQL injection via a network-accessible HTTP endpoint. No fake or detection-only scripts are present; the repository is a functional PoC for educational purposes.ianoboyle · Disclosed Oct 8, 2025 · python · bash · networkPoCCVE-2025-57833This repository is a proof-of-concept (POC) for CVE-2025-57833, targeting Django 5.2. The project is a Django web application with a PostgreSQL backend, set up for easy deployment via Docker. The main vulnerability is demonstrated in the 'Books' view (vuln/views.py), where the POST /book/search endpoint accepts a user-controlled 'alias' field that is used directly in a FilteredRelation ORM annotation. This could allow an attacker to manipulate the ORM query, potentially leading to SQL injection or other attacks depending on the underlying ORM and database behavior. The repository includes all necessary Django project files, migration scripts, and Docker configuration for local testing and exploitation. The exploit is triggered by sending a crafted POST request to /book/search with a JSON body containing the 'alias' and optional 'author' fields. No external network endpoints are hardcoded; the attack is performed via HTTP requests to the local application.sw0rd1ight · Disclosed Nov 2, 2025 · python · json · httpPoC
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-2025-57833 exploited in the wild?
As of Sep 25, 2026, Mallory has no reports of CVE-2025-57833 being exploited in the wild. It is not listed in CISA KEV.
Is there a public exploit for CVE-2025-57833?
Yes. Mallory tracks 6 public exploits or proofs of concept for CVE-2025-57833, the earliest disclosed Sep 5, 2025.
Is there a patch for CVE-2025-57833?
Upgrade Django to a fixed supported release: 4.2.24 or later on the 4.2 branch, 5.1.12 or later on the 5.1 branch, or 5.2.6 or later on the 5.2 branch. Apply vendor security errata for downstream packaged products that embed vulnerable Django versions.
What products are affected by CVE-2025-57833?
Djangoproject Django.
How severe is CVE-2025-57833?
CVE-2025-57833 has a CVSS v3.1 score of 8.1 (High) and an EPSS score of 27.1% (98th percentile) as of Sep 25, 2026.
Activity feed

Recent activity

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

View more in app →
+3 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 signatures1YARA, Sigma, Snort, and vendor rules, auto-deployed to your SIEM.
Vendor-by-vendor mappingCross-references every affected SKU, including bundled OEM variants.
Social activity19Community discussion across Reddit, Mastodon, and other social sources.