Vulnerabilities / CVE-2025-59681

critical

CVE-2025-59681

django: Potential SQL injection in QuerySet.annotate(), alias(), aggregate(), and extra() on MySQL and MariaDB1

Published Modified CWE 89
In the Trivy database since at least 24 Oct 2026, 07:11 UTCWhen it arrived before that build is not recorded.

Severity by source

NVD9.8CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GHSA7.1CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:N
Red Hat8.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N
Bitnami9.8CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

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

SourcePackageFixed in
bitnami::Bitnami Vulnerability Databasedjango4.2.25, 5.1.13, 5.2.7
alpine 3.22py3-django4.2.25-r0
alpine 3.23py3-django4.2.25-r0
alpine 3.24py3-django4.2.25-r0
alpine edgepy3-django4.2.25-r0
chainguardawx24.6.1-r17
debian 11python-django2:2.2.28-1~deb11u9
debian 12python-django3:3.2.25-0+deb12u1
debian 13python-django3:4.2.27-0+deb13u1
debian 14python-django3:4.2.25-1
echopython-django3:3.2.25-0+deb12u1
echo pip::Echo OSVdjango5.2.1+echo.1
Show all 33 entries from 30 sources
SourcePackageFixed in
bitnami::Bitnami Vulnerability Databasedjango4.2.25, 5.1.13, 5.2.7
alpine 3.22py3-django4.2.25-r0
alpine 3.23py3-django4.2.25-r0
alpine 3.24py3-django4.2.25-r0
alpine edgepy3-django4.2.25-r0
chainguardawx24.6.1-r17
debian 11python-django2:2.2.28-1~deb11u9
debian 12python-django3:3.2.25-0+deb12u1
debian 13python-django3:4.2.27-0+deb13u1
debian 14python-django3:4.2.25-1
echopython-django3:3.2.25-0+deb12u1
echo pip::Echo OSVdjango5.2.1+echo.1
pip::GitHub Security Advisory pipdjango4.2.25, 5.1.13, 5.2.7
rapidfort alpine 3.20py3-django4.2.25-r0
rapidfort alpine 3.21py3-django4.2.25-r0
rapidfort alpine 3.22py3-django4.2.25-r0
rapidfort alpine 3.23py3-django4.2.25-r0
rapidfort alpine 3.24py3-django4.2.25-r0
rapidfort debian 12python-django0:4.2.27-0+deb13u1, 3:4.2.25-1
rapidfort debian 13python-django0:4.2.27-0+deb13u1, 3:4.2.25-1
rapidfort fedora 43python-django55.2.9-1.fc43
rapidfort fedora 43python3-django5.2.9-1.fc43
rapidfort fedora 43python3-django-bash-completion5.2.9-1.fc43
rapidfort fedora 43python3-django-doc5.2.9-1.fc43
ubuntu 16.04-ESMpython-django1.8.7-1ubuntu5.15+esm9
ubuntu 18.04-ESMpython-django1:1.11.11-1ubuntu1.21+esm12
ubuntu 20.04-ESMpython-django2:2.2.12-1ubuntu0.29+esm4
ubuntu 22.04python-django2:3.2.12-2ubuntu1.22
ubuntu 24.04python-django3:4.2.11-1ubuntu1.11
ubuntu 25.04python-django3:4.2.18-1ubuntu1.5
ubuntu 25.10python-django3:5.2.4-1ubuntu2
ubuntu 26.04python-django3:5.2.4-1ubuntu2
ubuntu 26.10python-django3:5.2.4-1ubuntu2

References

All 16 references

Vulnerability data compiled from the Trivy vulnerability database (trivy-db, Aqua Security, Apache License 2.0), which aggregates third-party advisories. CVE records are published by The MITRE Corporation under the CVE Terms of Use; CVE is a trademark of MITRE. This product uses data from the NVD API but is not endorsed or certified by the NVD. Severity, titles and advisory data from the GitHub Advisory Database (CC BY 4.0), Red Hat security data (CC BY 4.0) and the other sources linked on each entry. Entries may be summarised or re-formatted; the linked original is the authoritative record.