high CVSS 7.1

CVE-2025-59681·MariaDB vulnerability

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).

Severity
high
Software
MariaDB
Fixed in
5.2.7
Published
2025-10-01

Affected versions

From: 5.2

Until: 5.2.7

Fixed in: 5.2.7

How to fix this CVE

MariaDB users running versions 5.2.0 through 5.2.6 must upgrade to 5.2.7 or later to patch a SQL injection vulnerability in query alias handling. This vulnerability allows authenticated users to inject malicious SQL through crafted dictionary arguments passed to QuerySet methods on MySQL and MariaDB backends. Immediate patching is recommended for production environments, especially those with untrusted database users or applications that construct dynamic queries.

sudo dnf update mariadb-server

Defensia detects this vulnerability

WAF mitigation (if patching is not yet possible)

Add this rule to your WAF to block exploitation attempts while you schedule the patch.

Implement input validation to restrict dictionary keys passed to Django ORM methods to alphanumeric characters and underscores only; block requests containing suspicious alias patterns with special characters, semicolons, or SQL keywords in column alias parameters.

How to check if you are affected

  1. Step 1: Check installed MariaDB version by running `mariadb --version` or connecting to the server and executing `SELECT VERSION();`
  2. Step 2: Verify if your application uses Django ORM with annotate(), alias(), aggregate(), or extra() methods that accept user-controlled dictionary arguments
  3. Step 3: Search MariaDB audit logs for suspicious SQL patterns containing unusual alias definitions or multiple consecutive column aliases with special characters: `grep -i 'alias' /var/log/mysql/audit.log | grep -E '["\'].*[;\-\-]'`
  4. Step 4: After patching, confirm the new version by running `mariadb --version` and verify query execution with a test annotate() call returns expected results without errors

FAQ

What is CVE-2025-59681?

CVE-2025-59681 is a SQL injection vulnerability in MariaDB where authenticated attackers can inject arbitrary SQL code through improperly sanitized column alias parameters in Django ORM query methods on MySQL and MariaDB systems.

Is CVE-2025-59681 being actively exploited?

No, CVE-2025-59681 is not currently listed in the CISA Known Exploited Vulnerabilities catalog and no public exploits are known at this time.

What versions of MariaDB are affected by CVE-2025-59681?

MariaDB versions 5.2.0 through 5.2.6 are vulnerable; version 5.2.7 and later include the fix.

How do I check if my server is vulnerable to CVE-2025-59681?

Connect to MariaDB and run `SELECT VERSION();` then compare against 5.2.7. If your version is between 5.2.0 and 5.2.6 inclusive, your server is vulnerable.

Does Defensia detect CVE-2025-59681?

Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If MariaDB is installed on a monitored server, CVE-2025-59681 will appear in your dashboard with remediation steps.

Related MariaDB CVEs

CVE-2026-49261CVSS 10MariaDB server is a community developed fork of MySQL server. Versions 10.6.1 through 10.6.26, 10.11.1 through 10.11.17, 11.4.1 through 11.4.11, 11.8.1 through 11.8.7, and 12.3.1 with `wsrep_notify_cmd` enabled would execute shell commands embedded in the name of the joiner node. This is fixed in 10.6.27, 10.11.18, 11.4.12, 11.8.8, and 12.3.2. As a workaround, anyone who cannot upgrade now should disable `wsrep_notify_cmd`.
CVE-2026-44170CVSS 9.8MariaDB server is a community developed fork of MySQL server. From versions 10.6.1 to before 10.6.26, 10.11.1 to before 10.11.17, 11.4.1 to before 11.4.11, 11.8.1 to before 11.8.7, and 12.3.1, MariaDB on WIndows with installed CONNECT engine and enabled REST support interpolated table HTTP attribute into the curl command line without proper sanitizing. This allows the user to execute shell commands on the server. This issue has been patched in versions 10.6.26, 10.11.17, 11.4.11, 11.8.7, and 12.3.2.
CVE-2026-22730CVSS 8.8A critical SQL injection vulnerability in Spring AI's MariaDBFilterExpressionConverter allows attackers to bypass metadata-based access controls and execute arbitrary SQL commands. The vulnerability exists due to missing input sanitization.
CVE-2026-32710CVSS 8.5MariaDB server is a community developed fork of MySQL server. An authenticated user can crash MariaDB versions 11.4 before 11.4.10 and 11.8 before 11.8.6 via a bug in JSON_SCHEMA_VALID() function. Under certain conditions it might be possible to turn the crash into a remote code execution. These conditions require tight control over memory layout which is generally only attainable in a lab environment. This issue is fixed in MariaDB 11.4.10, MariaDB 11.8.6, and MariaDB 12.2.2.
CVE-2026-44168CVSS 8MariaDB server is a community developed fork of MySQL server. From versions 10.6.1 to before 10.6.26, 10.11.1 to before 10.11.17, 11.4.1 to before 11.4.11, 11.8.1 to before 11.8.7, and 12.3.1, during the SST the donor node is interpolating parameters that the joiner sent into the command line. Not all parameters were properly validated which could allow a malicious joiner to execute arbitrary shell commands on the donor side via the mariabackup SST method. This issue has been patched in versions 10.6.26, 10.11.17, 11.4.11, 11.8.7, and 12.3.2.

References

Track CVEs across your fleet automatically

Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2025-59681. Free for 1 server.

Get started free