CVE-2025-13372: Django SQL Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-rqw2-ghq9-44m7
CVSS 4.3
CWE-89
Published
Advisory Summary

CVE-2025-13372 is a MODERATE (CVSS 4.3) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Django libraries in the PyPI ecosystem. The issue involves django is vulnerable to sql injection in column aliases. Remediation is available by upgrading affected packages to version 5.2.9, 5.1.15, 4.2.27.

CVE-2025-13372 at a Glance

CVE Identifier CVE-2025-13372
GHSA Identifier GHSA-rqw2-ghq9-44m7
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Django
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2025-13372

To remediate this vulnerability, upgrade all affected Django dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Django fixed: 5.2.9
pip install Django>=5.2.9
Django fixed: 5.1.15
pip install Django>=5.1.15
Django fixed: 4.2.27
pip install Django>=4.2.27
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Django

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-13372, inspect your installed packages using pip:

pip show Django

Analyze the terminal output to locate any version of Django in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.9), your application is affected.

Note: The pip show Django command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Django, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

An issue was discovered in 5.2 before 5.2.9, 5.1 before 5.1.15, and 4.2 before 4.2.27. `FilteredRelation` is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the `**kwargs` passed to `QuerySet.annotate()` or `QuerySet.alias()` on PostgreSQL. Earlier, unsupported Django series (such as 5.0.x, 4.1.x, and 3.2.x) were not evaluated and may also be affected. Django would like to thank Stackered for reporting this issue.

CVE-2025-13372 Affected Django Versions

3 component(s)
Fixed Versions:
5.2.95.1.154.2.27
Product / Package Ecosystem Affected Versions Fixed Version
Django
PyPI
≥ 5.2a1
< 5.2.9
5.2.9
Django
PyPI
≥ 5.1a1
< 5.1.15
5.1.15
Django
PyPI
≥ 4.2a1
< 4.2.27
4.2.27

References

Frequently Asked Questions

What is CVE-2025-13372?
CVE-2025-13372 is a security vulnerability in Django involving Django is vulnerable to SQL injection in column aliases under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Django versions are affected?
Affected versions include releases prior to 5.2.9, 5.1.15, 4.2.27 across affected packages: Django.
What version fixes CVE-2025-13372?
Upgrading to 5.2.9, 5.1.15, 4.2.27 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Django affected?
Yes, Django is affected in releases prior to 5.2.9, 5.1.15, 4.2.27. Upgrade your dependency to 5.2.9, 5.1.15, 4.2.27 or later.
What is the CVSS score of CVE-2025-13372?
CVE-2025-13372 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2025-13372?
CVE-2025-13372 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check PyPI dependencies for CVE-2025-13372?
Run the dependency tree command: 'pip show Django'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rqw2-ghq9-44m7",
  "modified" : "2026-06-05T14:34:14Z",
  "published" : "2025-12-02T18:30:35Z",
  "aliases" : [ "CVE-2025-13372" ],
  "summary" : "Django is vulnerable to SQL injection in column aliases",
  "details" : "An issue was discovered in 5.2 before 5.2.9, 5.1 before 5.1.15, and 4.2 before 4.2.27.\n`FilteredRelation` is subject to SQL injection in column aliases, using a suitably crafted dictionary, with dictionary expansion, as the `**kwargs` passed to `QuerySet.annotate()` or `QuerySet.alias()` on PostgreSQL.\nEarlier, unsupported Django series (such as 5.0.x, 4.1.x, and 3.2.x) were not evaluated and may also be affected.\nDjango would like to thank Stackered for reporting this issue.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.2a1"
      }, {
        "fixed" : "5.2.9"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.1a1"
      }, {
        "fixed" : "5.1.15"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.2a1"
      }, {
        "fixed" : "4.2.27"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-13372"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/479415ce5249bcdebeb6570c72df2a87f45a7bbf"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/56aea00c3c5e1aacf4ed05f8ee06c2e78f02cea0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/5b90ca1e7591fa36fccf2d6dad67cf1477e6293e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/9c6a5bde24240382807d13bc3748d08444709355"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/django/django/commit/f997037b235f6b5c9e7c4a501491ec45f3400f3d"
  }, {
    "type" : "WEB",
    "url" : "https://docs.djangoproject.com/en/dev/releases/security"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/django/django"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/django/PYSEC-2025-104.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/django-announce"
  }, {
    "type" : "WEB",
    "url" : "https://www.djangoproject.com/weblog/2025/dec/02/security-releases"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-12-03T14:07:25Z",
    "nvd_published_at" : "2025-12-02T16:15:53Z"
  }
}