CVE-2025-13372: Django SQL Injection Vulnerability in Column Aliases

django Updated 03 Dec 2025

Summary

02/12/2025
Yes i
Moderate
4.3

CVE-2025-13372: Django is vulnerable to SQL injection in column aliases. Affects django across 3 version ranges.

>= 4.2a1, < 4.2.27 >= 5.1a1, < 5.1.15 >= 5.2a1, < 5.2.9

Fixed in 4.2.27, 5.1.15 or 5.2.9, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2025-13372 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It provides a robust set of features for building web applications, including an ORM (Object-Relational Mapping) system that allows developers to interact with databases using Python code. However, certain versions of Django are vulnerable to SQL injection attacks, particularly in the handling of column aliases when using FilteredRelation with dictionary expansion in QuerySet.annotate() or QuerySet.alias() methods on PostgreSQL databases.

Vulnerability Detail

The vulnerability arises from improper handling of user input in column aliases, which can allow an attacker to inject malicious SQL code through crafted dictionaries passed as keyword arguments. This SQL injection vulnerability can lead to unauthorized data access, data manipulation, or even complete database compromise, depending on the attacker's intent and the application's database permissions. The affected versions include Django 5.2 before 5.2.9, 5.1 before 5.1.15, and 4.2 before 4.2.27. Unsupported versions such as 5.0.x, 4.1.x, and 3.2.x may also be at risk.

How To Fix

Latest published version: 6.1.2 as of 22 Oct 2026

pip install --upgrade "django==6.1.2"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 4.2a1, < 4.2.27 4.2.27
    pip install --upgrade "django==4.2.27"
  • >= 5.1a1, < 5.1.15 5.1.15
    pip install --upgrade "django==5.1.15"
  • >= 5.2a1, < 5.2.9 5.2.9
    pip install --upgrade "django==5.2.9"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a temporary workaround, avoid using FilteredRelation with dictionary expansion in your queries until you can upgrade to a secure version. Instead, consider using alternative methods to achieve the desired query results without exposing your application to SQL injection risks.

Conclusion

The SQL injection vulnerability in Django's handling of column aliases poses a significant risk to applications using affected versions. It is crucial to update to the latest patched versions to protect against potential attacks. Utilizing tools like Vulert can further enhance your security posture by providing real-time monitoring for vulnerabilities.

See every vulnerability recorded for django →

Share this vulnerability

FAQ

SQL injection is a code injection technique that exploits vulnerabilities in an application's software by allowing an attacker to interfere with the queries that an application makes to its database.

You can check your Django version and compare it with the affected versions listed in the vulnerability details. Additionally, you can use tools like Vulert to monitor and alert for open-source vulnerabilities.

If exploited, this vulnerability can lead to unauthorized access to sensitive data, data manipulation, and potentially full control over the database.

Yes, you can temporarily avoid using the vulnerable features, such as FilteredRelation with dictionary expansion, until you can upgrade to a secure version.

Vulert monitors and alerts for open-source vulnerabilities in your software using just the Pipfile.lock, allowing you to stay informed about potential risks without needing to access the code directly.

Related vulnerabilities

Recent vulnerabilities recorded for django.

How To Fix

Latest published version: 6.1.2 as of 22 Oct 2026

pip install --upgrade "django==6.1.2"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 4.2a1, < 4.2.27 4.2.27
    pip install --upgrade "django==4.2.27"
  • >= 5.1a1, < 5.1.15 5.1.15
    pip install --upgrade "django==5.1.15"
  • >= 5.2a1, < 5.2.9 5.2.9
    pip install --upgrade "django==5.2.9"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback