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-34265

CVE-2022-34265: Django Trunc/Extract SQL Injection Flaw

CVE-2022-34265 is a SQL injection vulnerability affecting Django 3.2 and 4.0 via Trunc() and Extract() database functions when untrusted data is used. This article covers technical details, affected versions, and mitigation steps.

Published: February 11, 2026

CVE-2022-34265 Overview

CVE-2022-34265 is a critical SQL Injection vulnerability affecting Django web framework versions 3.2 before 3.2.14 and 4.0 before 4.0.6. The vulnerability exists in the Trunc() and Extract() database functions, which are susceptible to SQL injection when untrusted data is used as a kind or lookup_name value. Applications that constrain the lookup name and kind choice to a known safe list are unaffected by this vulnerability.

Critical Impact

Remote attackers can exploit this SQL Injection vulnerability to execute arbitrary SQL commands against the database, potentially leading to unauthorized data access, data modification, or complete database compromise without requiring authentication.

Affected Products

  • Django 3.2 before 3.2.14
  • Django 4.0 before 4.0.6
  • Djangoproject Django (all affected versions)

Discovery Timeline

  • July 4, 2022 - CVE-2022-34265 published to NVD
  • July 4, 2022 - Django Project releases security patches
  • November 21, 2024 - Last updated in NVD database

Technical Details for CVE-2022-34265

Vulnerability Analysis

This SQL Injection vulnerability (CWE-89) resides in Django's ORM (Object-Relational Mapping) layer, specifically within the Trunc() and Extract() database functions. These functions are commonly used for date/time manipulation in Django queries, allowing developers to truncate or extract specific components from datetime fields.

The core issue stems from insufficient input validation when processing the kind parameter in Trunc() and the lookup_name parameter in Extract(). When these parameters accept user-controlled input without proper sanitization or validation against a safe allowlist, malicious SQL code can be injected directly into the generated database query.

An attacker exploiting this vulnerability can achieve full database compromise, including reading sensitive data from other tables, modifying or deleting records, and potentially executing administrative operations on the database server depending on the database configuration and privileges.

Root Cause

The root cause of CVE-2022-34265 is improper input validation in Django's database function handling. The Trunc() and Extract() functions directly interpolate the kind and lookup_name parameters into SQL queries without adequately sanitizing or validating them against an expected set of safe values. This allows attackers to break out of the intended SQL context and inject arbitrary SQL statements when user-controlled data flows into these parameters.

Attack Vector

The attack vector is network-based and requires no authentication or user interaction. An attacker can exploit this vulnerability by submitting crafted input through any application endpoint that passes user-controlled data to the Trunc() or Extract() database functions without proper validation.

For example, if an application allows users to specify date truncation preferences (such as "year", "month", "day") and passes this input directly to Trunc(), an attacker can inject SQL code instead of a legitimate truncation value. The injected SQL executes with the privileges of the database user configured for the Django application.

The vulnerability mechanism involves passing malicious input as the kind or lookup_name parameter to these database functions. When Django constructs the SQL query, the unsanitized parameter is embedded directly into the query string, allowing SQL injection. Detailed technical information is available in the Django Security Release Notes and the Django Weblog Security Releases.

Detection Methods for CVE-2022-34265

Indicators of Compromise

  • Unusual SQL error messages in application logs containing unexpected date/time function syntax
  • Database query logs showing malformed DATE_TRUNC, EXTRACT, or equivalent date manipulation functions with suspicious payloads
  • Evidence of data exfiltration, unauthorized database queries, or unexpected data modifications
  • Web application firewall or intrusion detection alerts for SQL injection patterns in request parameters

Detection Strategies

  • Monitor application logs for SQL syntax errors related to date/time functions that may indicate injection attempts
  • Deploy web application firewalls (WAF) with SQL injection detection rules focused on date manipulation function patterns
  • Implement database activity monitoring to detect anomalous queries involving Trunc() or Extract() operations
  • Conduct code review to identify instances where user input flows to the kind or lookup_name parameters without validation

Monitoring Recommendations

  • Enable detailed logging for Django database queries in non-production environments to identify vulnerable code paths
  • Configure database audit logging to capture all queries executed against sensitive tables
  • Set up alerting for repeated SQL syntax errors that may indicate active exploitation attempts
  • Monitor for unexpected database connections or privilege escalation activities

How to Mitigate CVE-2022-34265

Immediate Actions Required

  • Upgrade Django to version 3.2.14 or later for the 3.2.x branch
  • Upgrade Django to version 4.0.6 or later for the 4.0.x branch
  • Audit all application code for uses of Trunc() and Extract() functions that accept user input
  • Implement strict allowlist validation for kind and lookup_name parameters before passing to database functions

Patch Information

Django has released security patches addressing this vulnerability. The fixes are included in Django versions 3.2.14 and 4.0.6. Organizations should upgrade to these versions or later immediately. Detailed patch information and release notes are available from the Django Security Release Notes and the official Django Weblog Security Releases.

Additional advisories have been published by downstream distributors including Debian Security Advisory DSA-5254, Fedora Package Announcements, and NetApp Security Advisory.

Workarounds

  • Constrain the kind and lookup_name parameters to a predefined allowlist of safe values (e.g., year, month, day, hour, minute, second)
  • Validate all user input against expected patterns before passing to database functions
  • Implement input sanitization as a defense-in-depth measure even if using an allowlist
  • Consider using parameterized values only from application code rather than accepting user-specified date truncation options
python
# Example allowlist validation for Trunc() kind parameter
SAFE_TRUNC_KINDS = {'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second'}

def safe_trunc(queryset, field_name, kind):
    if kind not in SAFE_TRUNC_KINDS:
        raise ValueError(f"Invalid truncation kind: {kind}")
    return queryset.annotate(truncated=Trunc(field_name, kind))

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 Probability92.83%

  • 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 Announce Google Group

  • Fedora Package Announcement

  • Fedora Package Announcement

  • NetApp Security Advisory

  • Debian Security Advisory DSA-5254
  • Vendor Resources
  • 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-28347: Django QuerySet SQL Injection Vulnerability
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