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-2025-59681

CVE-2025-59681: Django SQL Injection Vulnerability

CVE-2025-59681 is a SQL injection vulnerability in Django affecting QuerySet methods on MySQL and MariaDB databases. Attackers can exploit column aliases via crafted dictionaries. Learn about affected versions and mitigations.

Published: March 11, 2026

CVE-2025-59681 Overview

A SQL injection vulnerability has been discovered in Django, one of the most widely used Python web frameworks. This vulnerability affects the QuerySet.annotate(), QuerySet.alias(), QuerySet.aggregate(), and QuerySet.extra() methods, allowing attackers to inject malicious SQL code through column aliases when using dictionary expansion with specially crafted dictionaries as **kwargs. The vulnerability specifically impacts applications running on MySQL and MariaDB database backends.

Critical Impact

Attackers can exploit this vulnerability to execute arbitrary SQL commands, potentially leading to unauthorized data access, data modification, or complete database compromise on affected Django applications using MySQL or MariaDB.

Affected Products

  • Django 4.2 before 4.2.25
  • Django 5.1 before 5.1.13
  • Django 5.2 before 5.2.7

Discovery Timeline

  • October 1, 2025 - CVE-2025-59681 published to NVD
  • October 1, 2025 - Django Project releases security patches
  • November 4, 2025 - Last updated in NVD database

Technical Details for CVE-2025-59681

Vulnerability Analysis

This SQL injection vulnerability (CWE-89) exists in Django's ORM layer, specifically within methods that accept column aliases as keyword arguments. When developers use dictionary expansion (**kwargs) to pass dynamically constructed dictionaries to QuerySet.annotate(), QuerySet.alias(), QuerySet.aggregate(), or QuerySet.extra(), an attacker who can control the dictionary keys can inject malicious SQL through these column alias names.

The vulnerability is particularly dangerous because column aliases are typically not considered user-controllable input, and many applications may pass user-influenced data through these methods without proper sanitization. The issue is limited to MySQL and MariaDB backends due to differences in how these databases handle identifier quoting compared to other database systems like PostgreSQL.

Root Cause

The root cause stems from insufficient sanitization of column alias names when constructing SQL queries. Django's ORM typically escapes values to prevent SQL injection, but the alias names (which become column identifiers in the generated SQL) were not being properly validated or escaped when using dictionary expansion. On MySQL and MariaDB, attackers can craft dictionary keys containing SQL metacharacters that break out of the expected identifier context and inject arbitrary SQL statements.

Attack Vector

This vulnerability is exploitable over the network without authentication or user interaction. An attacker would need to find an application endpoint where:

  1. User input influences the keys of a dictionary passed to one of the vulnerable QuerySet methods
  2. The dictionary is expanded using **kwargs syntax
  3. The application uses MySQL or MariaDB as its database backend

The vulnerability mechanism involves crafting dictionary keys with SQL injection payloads that, when used as column aliases, allow the attacker to modify the query structure. Because the alias appears in the SELECT clause of the generated SQL, successful exploitation could allow attackers to extract sensitive data from other tables, modify database records, or execute administrative operations depending on database permissions. See the Django Weblog Security Releases for additional technical details.

Detection Methods for CVE-2025-59681

Indicators of Compromise

  • Unusual SQL error messages in application logs indicating malformed queries or unexpected column aliases
  • Database query logs showing queries with suspicious column alias names containing SQL keywords or special characters
  • Unexpected data access patterns in database audit logs
  • Application errors related to QuerySet methods with dictionary expansion

Detection Strategies

  • Monitor web application logs for requests containing SQL metacharacters in parameters that may influence QuerySet method arguments
  • Implement database query logging and alerting for queries with unusual column alias patterns
  • Deploy web application firewalls (WAF) with rules to detect SQL injection attempts in request parameters
  • Review application code for usages of annotate(), alias(), aggregate(), and extra() with dictionary expansion from user-controllable sources

Monitoring Recommendations

  • Enable detailed query logging on MySQL/MariaDB databases to capture column alias information
  • Configure intrusion detection systems to alert on SQL injection signature patterns
  • Monitor Django application error rates for increases that may indicate exploitation attempts
  • Implement runtime application self-protection (RASP) to detect SQL injection attempts at the application layer

How to Mitigate CVE-2025-59681

Immediate Actions Required

  • Upgrade Django to patched versions: 4.2.25, 5.1.13, or 5.2.7 or later
  • Review application code for vulnerable patterns using QuerySet methods with dictionary expansion from user input
  • Implement input validation to ensure dictionary keys used in QuerySet methods contain only safe characters
  • Consider temporarily switching to PostgreSQL if immediate patching is not possible

Patch Information

The Django Project has released security patches addressing this vulnerability. Updated versions are available:

  • Django 4.2.25 for the 4.2.x LTS branch
  • Django 5.1.13 for the 5.1.x branch
  • Django 5.2.7 for the 5.2.x branch

Patches are available through the official Django releases. For more information, refer to the Django Security Release Notes and the Django Weblog Security Releases.

Workarounds

  • Avoid using dictionary expansion (**kwargs) with user-controllable data in QuerySet methods until patching is complete
  • Implement strict allowlisting of acceptable column alias names before passing to QuerySet methods
  • Use static, hardcoded column aliases rather than dynamically generated ones from user input
  • Add application-level validation to reject dictionary keys containing SQL metacharacters
bash
# Upgrade Django to patched version
pip install --upgrade Django>=4.2.25  # For Django 4.2.x
pip install --upgrade Django>=5.1.13  # For Django 5.1.x
pip install --upgrade Django>=5.2.7   # For Django 5.2.x

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

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

  • Vulnerability Details
  • TypeSQLI

  • Vendor/TechDjangoproject Django

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability0.01%

  • 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
  • Openwall OSS-Security Post
  • Vendor Resources
  • Django Security Release Notes

  • Django Announcements Group

  • Django Weblog Security Releases
  • Related CVEs
  • CVE-2026-1312: Djangoproject Django SQLi Vulnerability

  • CVE-2026-1207: Django SQLi Vulnerability in RasterField

  • CVE-2025-57833: Django FilteredRelation SQL Injection Flaw

  • CVE-2024-42005: Django JSONField 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