CVE-2021-35042

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

published July 2, 2021

CVSS
—
EPSS
44%
Percentile
98.8
In the wild
Unconfirmed
What it is

⚠️ Watch out, Django developers! An untrusted input can lead to SQL injection via QuerySet.order_by — it's like letting a customer in the kitchen to rearrange the ingredients without supervision! Imagine a restaurant where customers can mess with the chef's recipe book. If they can randomly change the order of ingredients, the final dish could taste awful or even be unsafe. That's what happens when unvetted input is allowed in order_by clauses! An attacker could manipulate query results, potentially gaining access to sensitive data or altering the output unexpectedly. This could lead to unauthorized data exposure or even server-side issues, making your application vulnerable.

Put simply

Imagine a restaurant where customers can mess with the chef's recipe book. If they can randomly change the order of ingredients, the final dish could taste awful or even be unsafe. That's what happens when unvetted input is allowed in order_by clauses! Django versions 3.1.x before 3.1.13 and 3.2.x before 3.2.5 are susceptible to SQL injection when the order_by parameter is influenced by untrusted client input, allowing attackers to inject harmful SQL commands.

What to do

An attacker could manipulate query results, potentially gaining access to sensitive data or altering the output unexpectedly. This could lead to unauthorized data exposure or even server-side issues, making your application vulnerable. Upgrade Django to version 3.1.13 or 3.2.5 immediately to patch this vulnerability. Additionally, always ensure that any client input is validated and sanitized before use in database queries. Implementing further security checks can also bolster your defenses. You've got this! With these updates, you'll secure your application and protect your users. 🛡️

The record
Technical detail
CVSS
Not scored
CVSS v4.0
Not supplied
EPSS
0.44369 · 98.8th percentile
Published
2021-07-02T09:54Z
EPSS history
Timeline
  • 02 JUL 09:54Z
    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
    cvelistv5