CVE-2025-59681
django: Potential SQL injection in QuerySet.annotate(), alias(), aggregate(), and extra() on MySQL and MariaDB1
Severity by source
Trivy's own label is CRITICAL. Rated critical by NVD, Bitnami. Rated lower by GHSA (high), Red Hat (high), Ubuntu (medium).
Description
An issue was discovered in Django 4.2 before 4.2.25, 5.1 before 5.1.13, and 5.2 before 5.2.7. QuerySet.annotate(), QuerySet.alias(), QuerySet.aggregate(), and QuerySet.extra() are subject to SQL injection in column aliases, when using a suitably crafted dictionary, with dictionary expansion, as the **kwargs passed to these methods (on MySQL and MariaDB).
Affected packages and fixed versions
| Source | Package | Fixed in |
|---|---|---|
| bitnami::Bitnami Vulnerability Database | django | 4.2.25, 5.1.13, 5.2.7 |
| alpine 3.22 | py3-django | 4.2.25-r0 |
| alpine 3.23 | py3-django | 4.2.25-r0 |
| alpine 3.24 | py3-django | 4.2.25-r0 |
| alpine edge | py3-django | 4.2.25-r0 |
| chainguard | awx | 24.6.1-r17 |
| debian 11 | python-django | 2:2.2.28-1~deb11u9 |
| debian 12 | python-django | 3:3.2.25-0+deb12u1 |
| debian 13 | python-django | 3:4.2.27-0+deb13u1 |
| debian 14 | python-django | 3:4.2.25-1 |
| echo | python-django | 3:3.2.25-0+deb12u1 |
| echo pip::Echo OSV | django | 5.2.1+echo.1 |
Show all 33 entries from 30 sources
| Source | Package | Fixed in |
|---|---|---|
| bitnami::Bitnami Vulnerability Database | django | 4.2.25, 5.1.13, 5.2.7 |
| alpine 3.22 | py3-django | 4.2.25-r0 |
| alpine 3.23 | py3-django | 4.2.25-r0 |
| alpine 3.24 | py3-django | 4.2.25-r0 |
| alpine edge | py3-django | 4.2.25-r0 |
| chainguard | awx | 24.6.1-r17 |
| debian 11 | python-django | 2:2.2.28-1~deb11u9 |
| debian 12 | python-django | 3:3.2.25-0+deb12u1 |
| debian 13 | python-django | 3:4.2.27-0+deb13u1 |
| debian 14 | python-django | 3:4.2.25-1 |
| echo | python-django | 3:3.2.25-0+deb12u1 |
| echo pip::Echo OSV | django | 5.2.1+echo.1 |
| pip::GitHub Security Advisory pip | django | 4.2.25, 5.1.13, 5.2.7 |
| rapidfort alpine 3.20 | py3-django | 4.2.25-r0 |
| rapidfort alpine 3.21 | py3-django | 4.2.25-r0 |
| rapidfort alpine 3.22 | py3-django | 4.2.25-r0 |
| rapidfort alpine 3.23 | py3-django | 4.2.25-r0 |
| rapidfort alpine 3.24 | py3-django | 4.2.25-r0 |
| rapidfort debian 12 | python-django | 0:4.2.27-0+deb13u1, 3:4.2.25-1 |
| rapidfort debian 13 | python-django | 0:4.2.27-0+deb13u1, 3:4.2.25-1 |
| rapidfort fedora 43 | python-django5 | 5.2.9-1.fc43 |
| rapidfort fedora 43 | python3-django | 5.2.9-1.fc43 |
| rapidfort fedora 43 | python3-django-bash-completion | 5.2.9-1.fc43 |
| rapidfort fedora 43 | python3-django-doc | 5.2.9-1.fc43 |
| ubuntu 16.04-ESM | python-django | 1.8.7-1ubuntu5.15+esm9 |
| ubuntu 18.04-ESM | python-django | 1:1.11.11-1ubuntu1.21+esm12 |
| ubuntu 20.04-ESM | python-django | 2:2.2.12-1ubuntu0.29+esm4 |
| ubuntu 22.04 | python-django | 2:3.2.12-2ubuntu1.22 |
| ubuntu 24.04 | python-django | 3:4.2.11-1ubuntu1.11 |
| ubuntu 25.04 | python-django | 3:4.2.18-1ubuntu1.5 |
| ubuntu 25.10 | python-django | 3:5.2.4-1ubuntu2 |
| ubuntu 26.04 | python-django | 3:5.2.4-1ubuntu2 |
| ubuntu 26.10 | python-django | 3:5.2.4-1ubuntu2 |
References
- http://www.openwall.com/lists/oss-security/2025/10/01/3
- https://access.redhat.com/security/cve/CVE-2025-59681
- https://advisory.echohq.com/cve/CVE-2025-59681
- https://docs.djangoproject.com/en/dev/releases/security
- https://docs.djangoproject.com/en/dev/releases/security/
- https://github.com/advisories/GHSA-hpr9-3m2g-3j9p
- https://github.com/django/django
- https://github.com/django/django/commit/41b43c74bda19753c757036673ea9db74acf494a
All 16 references
- https://github.com/django/django/commit/43d84aef04a9e71164c21a74885996981857e66e
- https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2025-106.yaml
- https://groups.google.com/g/django-announce
- https://nvd.nist.gov/vuln/detail/CVE-2025-59681
- https://ubuntu.com/security/notices/USN-7794-1
- https://www.cve.org/CVERecord?id=CVE-2025-59681
- https://www.djangoproject.com/weblog/2025/oct/01/security-releases
- https://www.djangoproject.com/weblog/2025/oct/01/security-releases/