The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2022-28346

CVE-2022-28346: Django SQL Injection Vulnerability

CVE-2022-28346 is a SQL injection vulnerability in Django affecting QuerySet methods through crafted dictionary expansion. This article covers the technical details, affected versions, security impact, and mitigation.

Published: February 17, 2026

CVE-2022-28346 Overview

CVE-2022-28346 is a SQL Injection vulnerability affecting Django, the popular Python web framework. The vulnerability exists in the QuerySet.annotate(), aggregate(), and extra() methods, which are susceptible to SQL injection attacks through crafted dictionary arguments passed via **kwargs. An attacker can exploit this flaw by injecting malicious SQL code into column aliases when dictionary expansion is used.

Critical Impact

This vulnerability allows remote attackers to execute arbitrary SQL commands against the database backend without authentication. Successful exploitation could lead to complete database compromise, including unauthorized data access, data modification, or data destruction.

Affected Products

  • Django versions 2.2 before 2.2.28
  • Django versions 3.2 before 3.2.13
  • Django versions 4.0 before 4.0.4
  • Debian Linux 9.0 and 11.0 (packages using vulnerable Django versions)

Discovery Timeline

  • 2022-04-11 - Django Project releases security advisory and patches
  • 2022-04-12 - CVE-2022-28346 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-28346

Vulnerability Analysis

This SQL Injection vulnerability (CWE-89) stems from insufficient sanitization of column alias names in Django's QuerySet methods. The annotate(), aggregate(), and extra() methods accept keyword arguments that define column aliases for aggregated or annotated fields. When an attacker controls the keys of a dictionary that is expanded using the **kwargs syntax, they can inject malicious SQL code into the resulting query.

The vulnerability is particularly dangerous because Django's ORM is widely trusted to provide protection against SQL injection attacks. Developers may not expect that column alias names require additional sanitization, making this an unexpected attack vector in otherwise secure code.

Root Cause

The root cause lies in how Django processes dictionary keys when they are used as column aliases in SQL queries. When a dictionary is passed to methods like annotate() or aggregate() using **kwargs expansion, Django uses the dictionary keys directly as column aliases in the generated SQL without proper escaping or validation. This allows an attacker who can control dictionary keys to inject arbitrary SQL syntax.

The issue specifically affects scenarios where user-controlled data influences the structure of dictionaries that are subsequently expanded in QuerySet method calls. This pattern can occur in applications that dynamically build queries based on user input or configuration data.

Attack Vector

The attack is network-based and requires no authentication or user interaction, making it highly exploitable in web applications. An attacker can craft malicious requests where user input eventually becomes dictionary keys that are expanded in vulnerable QuerySet method calls.

For example, if an application allows users to specify field names for aggregation and those names are used as dictionary keys without validation, an attacker could inject SQL code through specially crafted field names. The injected code would execute within the context of the database connection used by the Django application.

The vulnerability manifests when crafted dictionaries are passed to Django ORM methods. For detailed technical analysis, refer to the Django Weblog Security Releases advisory.

Detection Methods for CVE-2022-28346

Indicators of Compromise

  • Unusual SQL query patterns in database logs containing unexpected column aliases or SQL syntax in alias positions
  • Error logs showing SQL syntax errors with suspicious content in alias fields
  • Database audit logs revealing queries with injected commands in annotation or aggregation clauses
  • Web application logs showing requests with special characters or SQL keywords in form fields or URL parameters that map to aggregation fields

Detection Strategies

  • Implement Web Application Firewall (WAF) rules to detect SQL injection patterns in request parameters
  • Monitor Django application logs for ORM errors or unexpected query patterns involving annotate(), aggregate(), or extra() methods
  • Deploy database activity monitoring to detect anomalous query structures or privilege escalation attempts
  • Use Static Application Security Testing (SAST) tools to identify code patterns where user input flows into dictionary keys used in QuerySet methods

Monitoring Recommendations

  • Enable detailed SQL query logging in development and staging environments to identify potentially vulnerable query patterns
  • Implement runtime application self-protection (RASP) to detect SQL injection attempts in real-time
  • Set up alerts for database errors related to SQL syntax issues that may indicate exploitation attempts
  • Review Django debug logs for QuerySet operations that include unexpected characters in column aliases

How to Mitigate CVE-2022-28346

Immediate Actions Required

  • Upgrade Django to patched versions: 2.2.28, 3.2.13, or 4.0.4 or later immediately
  • Audit application code for patterns where user input may influence dictionary keys used in annotate(), aggregate(), or extra() calls
  • Implement input validation to ensure that any user-controlled data used in QuerySet method arguments contains only expected characters
  • Consider implementing a Web Application Firewall as a temporary protective measure while upgrades are deployed

Patch Information

The Django Project has released security patches addressing this vulnerability. Affected users should upgrade to the following fixed versions:

  • Django 2.2.28 for the 2.2 LTS branch
  • Django 3.2.13 for the 3.2 LTS branch
  • Django 4.0.4 for the 4.0 release series

Detailed patch information and release notes are available in the Django Security Release Notes. Linux distribution users should also apply updates from their package managers, as documented in the Debian Security Advisory DSA-5254 and Fedora Package Announcements.

Workarounds

  • Validate and sanitize all dictionary keys before using them in QuerySet method calls with **kwargs expansion
  • Implement an allowlist of permitted column alias names and reject any input not matching the allowlist
  • Avoid using user-controlled data as dictionary keys in Django ORM queries; use static keys and map user input to predetermined values
  • Consider using parameterized queries or Django's F() expressions instead of dynamic annotation names where possible
bash
# Upgrade Django to patched version
pip install --upgrade Django>=3.2.13

# Verify installed version
python -c "import django; print(django.VERSION)"

# For production deployments, update requirements.txt
# Django>=3.2.13,<4.0  # For 3.2 LTS users
# Django>=4.0.4        # For 4.0 users

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeSQLI

  • Vendor/TechDjango

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability2.22%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-89
  • Technical References
  • Django Announcement Forum

  • Debian LTS Advisory Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • NetApp Security Advisory NTAP-20220609-0002

  • Debian Security Advisory DSA-5254
  • Vendor Resources
  • OpenWall OSS Security Discussion

  • Django Security Release Notes

  • Django Weblog Security Releases
  • Related CVEs
  • CVE-2026-1287: Django FilteredRelation SQLi Vulnerability

  • CVE-2025-64459: Django QuerySet SQL Injection Vulnerability

  • CVE-2024-53908: Django HasKey Lookup SQLi Vulnerability

  • CVE-2022-34265: Django Trunc/Extract SQL Injection Flaw
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English