CVE-2021-35042

CRITICAL NUCLEI LAB

Django <3.1.13, <3.2.5 - SQL Injection

Title source: llm
STIX 2.1

Exploitation Summary

EIP tracks 7 public exploits for CVE-2021-35042. PoCs published by YouGina, r4vi, zer0qs. A Nuclei detection template is also available.

AI-analyzed exploit summary This repository contains a functional Django application demonstrating CVE-2021-35042, a SQL injection vulnerability via unsanitized QuerySet.order_by() input. The exploit is triggered by manipulating the 'order_by' parameter in the URL, allowing arbitrary SQL injection.

Description

Django 3.1.x before 3.1.13 and 3.2.x before 3.2.5 allows QuerySet.order_by SQL injection if order_by is untrusted input from a client of a web application.

Exploits (7)

nomisec WORKING POC 13 stars
by YouGina · poc
https://github.com/YouGina/CVE-2021-35042

This repository contains a functional Django application demonstrating CVE-2021-35042, a SQL injection vulnerability via unsanitized QuerySet.order_by() input. The exploit is triggered by manipulating the 'order_by' parameter in the URL, allowing arbitrary SQL injection.

Classification
Working Poc 95%
Attack Type
Sqli
Complexity
Trivial
Reliability
Reliable
Target: Django (versions affected by CVE-2021-35042)
No auth needed
Prerequisites: Django application with vulnerable QuerySet.order_by() usage · Access to the vulnerable endpoint
devstral-2 · analyzed Feb 18, 2026 Full analysis →
nomisec WORKING POC 5 stars
by r4vi · poc
https://github.com/r4vi/CVE-2021-35042

This repository contains a functional proof-of-concept for CVE-2021-35042, demonstrating a SQL injection vulnerability in Django's ORM. It includes a Django application with a vulnerable view that allows arbitrary SQL execution via the `order_by` parameter, with detailed steps to exploit it on both SQLite and PostgreSQL.

Classification
Working Poc 100%
Attack Type
Sqli
Complexity
Moderate
Reliability
Reliable
Target: Django (versions before 3.2.5)
No auth needed
Prerequisites: Django application with vulnerable ORM usage · Exposed endpoint with user-controlled `order_by` parameter
devstral-2 · analyzed Feb 18, 2026 Full analysis →
nomisec WRITEUP 2 stars
by zer0qs · poc
https://github.com/zer0qs/CVE-2021-35042

This repository provides a detailed technical analysis of CVE-2021-35042, a SQL injection vulnerability in Django's QuerySet.order_by() function. It explains the root cause, affected versions, and the flawed input validation logic that allows SQL injection via table names in order_by() queries.

Classification
Writeup 95%
Attack Type
Sqli
Complexity
Moderate
Reliability
Reliable
Target: Django 3.1.x < 3.1.13, 3.2.x < 3.2.5
No auth needed
Prerequisites: Django application using vulnerable versions · User-controlled input passed to order_by()
devstral-2 · analyzed Feb 18, 2026 Full analysis →
nomisec WORKING POC
by vutiendat323 · poc
https://github.com/vutiendat323/INT14107_CVE-2021-35042

This repository contains a functional exploit for CVE-2021-35042, a Django 3.2.4 SQL injection vulnerability in the order_by() function. The exploit leverages error-based SQL injection via the extractvalue() function to dump the database, including a custom script and sqlmap guide for exploitation.

Classification
Working Poc 95%
Attack Type
Sqli
Complexity
Moderate
Reliability
Reliable
Target: Django 3.2.4
No auth needed
Prerequisites: Django application with vulnerable order_by() usage · Access to the /posts/ endpoint with the 'sort' parameter
devstral-2 · analyzed Jun 05, 2026 Full analysis →
nomisec WRITEUP
by LUUANHDUC · poc
https://github.com/LUUANHDUC/CVE-2021-35042

This repository provides a detailed technical analysis of CVE-2021-35042, a SQL injection vulnerability in Django's QuerySet.order_by() function. It includes root cause analysis, code snippets, and explanations of how improper input validation leads to SQL injection.

Classification
Writeup 95%
Attack Type
Sqli
Complexity
Moderate
Reliability
Reliable
Target: Django 3.1.x < 3.1.13, 3.2.x < 3.2.5
No auth needed
Prerequisites: Django application with vulnerable version · Ability to send crafted input to order_by() function
devstral-2 · analyzed Feb 18, 2026 Full analysis →
nomisec WORKING POC
by mrlihd · poc
https://github.com/mrlihd/CVE-2021-35042

This repository contains a functional Django application demonstrating CVE-2021-35042, a SQL injection vulnerability via untrusted input in QuerySet.order_by(). The vulnerable endpoint allows arbitrary SQL injection through the 'order_by' parameter.

Classification
Working Poc 95%
Attack Type
Sqli
Complexity
Trivial
Reliability
Reliable
Target: Django 3.2.4 (and earlier versions)
No auth needed
Prerequisites: Django application with vulnerable QuerySet.order_by() usage
devstral-2 · analyzed Feb 18, 2026 Full analysis →
inthewild WRITEUP
poc
https://github.com/zh0ngs0n1337/cve-2021-35042

This repository provides a detailed technical analysis of CVE-2021-35042, a SQL injection vulnerability in Django's QuerySet.order_by() function. It includes an explanation of the root cause, affected versions, and the flawed input validation logic in Django's ORM.

Classification
Writeup 95%
Attack Type
Sqli
Complexity
Moderate
Reliability
Reliable
Target: Django 3.1.x < 3.1.13, 3.2.x < 3.2.5
No auth needed
Prerequisites: Django application using vulnerable versions · User-controlled input passed to order_by()
devstral-2 · analyzed Feb 23, 2026 Full analysis →

Nuclei Templates (1)

Django QuerySet.order_by - SQL Injection
CRITICALVERIFIEDby 0x_Akoko
FOFA: body="ProgrammingError" && body="ORDER BY"

References (6)

Core 6
Core References
Patch, Vendor Advisory x_refsource_misc
https://docs.djangoproject.com/en/3.2/releases/security/
Mailing List, Patch, Third Party Advisory x_refsource_confirm
https://www.openwall.com/lists/oss-security/2021/07/02/2
Patch, Vendor Advisory x_refsource_confirm
https://www.djangoproject.com/weblog/2021/jul/01/security-releases/
Third Party Advisory x_refsource_confirm
https://security.netapp.com/advisory/ntap-20210805-0008/

Scores

CVSS v3 9.8
EPSS 0.9090
EPSS Percentile 99.7%
Attack Vector NETWORK
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Details

CWE
CWE-89
Status published
Products (3)
djangoproject/django 3.1 - 3.1.13
fedoraproject/fedora 34
pypi/Django 3.2a1 - 3.2.5PyPI
Published Jul 02, 2021
Tracked Since Feb 18, 2026