SQL Injection Vulnerability in Django Package: CVE-2022-28346

python-django Updated 02 Oct 2025

Summary

12/04/2022
N/A
Yes i
Critical
9.8

CVE-2022-28346: An issue was discovered in Django 2.2 before 2.2.28, 3.2 before 3.2.13, and 4.0 before 4.0.4. Affects python-django across 2 version ranges.

< 2:2.2.28-1~deb11u1 >= 635d53a86a36cde7866b9caefeb64d809e6bfcd9, < 5c3300027b30c1b498d99010f7d618316f685045

Fixed in 2:2.2.28-1~deb11u1. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

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 instead of SQL. However, certain methods within Django's ORM, specifically QuerySet.annotate(), aggregate(), and extra(), are vulnerable to SQL injection attacks when crafted dictionaries are passed as keyword arguments. This vulnerability affects multiple versions of Django, including 2.2, 3.2, and 4.0, prior to their respective patch releases.

Vulnerability Detail

The vulnerability arises from improper handling of user input in the QuerySet methods, allowing attackers to inject malicious SQL code through crafted dictionaries. This can lead to unauthorized data access, data manipulation, or even complete database compromise. The issue is particularly concerning as it can be exploited without authentication, making it a critical security risk for applications using affected versions of Django. The CVSS score for this vulnerability is 9.8, indicating a high severity level.

How To Fix

Minimum fixed version

2:2.2.28-1~deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate upgrading is not possible, consider implementing input validation and sanitization on user inputs that are passed to the QuerySet methods. This can help mitigate the risk of SQL injection until the package can be updated.

Conclusion

CVE-2022-28346 represents a significant security risk for applications using vulnerable versions of Django. It is crucial for developers to upgrade to the patched versions to protect their applications from potential SQL injection attacks. Regular monitoring for vulnerabilities using tools like Vulert can help maintain application security.

See every vulnerability recorded for python-django →

Share this vulnerability

FAQ

CVE-2022-28346 is a vulnerability in Django that allows for SQL injection through improperly handled keyword arguments in certain QuerySet methods.

Django versions 2.2 before 2.2.28, 3.2 before 3.2.13, and 4.0 before 4.0.4 are affected by this vulnerability.

Exploitation of this vulnerability can lead to unauthorized access to sensitive data, data manipulation, and complete database compromise.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score for CVE-2022-28346 is 9.8, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for python-django.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

2:2.2.28-1~deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python-django

Tip — Not sure which version your app runs? Vulert can match this fix to it. 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