CVE-2021-35042 is a critical-severity (CVSS 9.8) SQL Injection vulnerability in django. 5 public exploit references exist, so weaponization risk is real. A fix is available for django — see the affected versions and patch details below.
SQL Injection in Django
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2021-35042 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 385,987 CVEs with a current EPSS score, this one falls in the 10–50% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
django🐍djangoReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | django | ≥ 3.2a1&&< 3.2.5 | 3.2.5pip install --upgrade 'django==3.2.5' |
| 🐍PyPI | django | ≥ 3.0a1&&< 3.1.13 | 3.1.13pip install --upgrade 'django==3.1.13' |
Affected Products
djangodjangoprojectfedorafedoraprojectResearch use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for django, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update django to 3.2.5 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-35042 is resolved across your whole dependency graph.
Workarounds
Until you can upgrade, make sure every query built from user input uses parameterised statements or a prepared-statement API rather than string concatenation, and reduce the database account's privileges so an injected query cannot read or alter data beyond what the feature needs.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
Mitigation for this issue is either not available or the currently available options do not meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.Source: Red Hat security advisory for CVE-2021-35042 (CC BY 4.0)
Frequently Asked Questions
Is CVE-2021-35042 in your dependencies?
Find it across PyPI, including transitive dependencies.