CVE-2024-21520: Cross-site Scripting in djangorestframework
Low CVSS 6.1
- OSV id
- GHSA-gw84-84pc-xp82
- Also known as
- CVE-2024-21520, PYSEC-2026-1304
- Published
- Last modified
Affected packages
| Package | Affected versions | Fixed in |
|---|---|---|
| djangorestframework PyPI |
< 3.15.2 | 3.15.2 |
Versions we track that it affects: djangorestframework 3.15.1
How to fix it
Upgrade djangorestframework to 3.15.2 or later.
# in requirements.txt: change the line to djangorestframework==3.15.2
pip install -r requirements.txt
- If it is an indirect dependency, upgrade the package that depends on it, or add a minimum version constraint for it (e.g. in constraints.txt, or as a dependency in pyproject.toml).
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
Not sure whether your project uses an affected version? Check your lockfile below for free.
Details
Versions of the package djangorestframework before 3.15.2 are vulnerable to Cross-site Scripting (XSS) via the breaklongheaders template filter due to improper input sanitization before splitting and joining with <br> tags.
References
- GHSA-gw84-84pc-xp82 on OSV.dev
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2024-21520
- Web: https://github.com/encode/django-rest-framework/pull/9435
- Web: https://github.com/encode/django-rest-framework/commit/3b41f0124194430da957b119712978fa2266b642
- Package: https://github.com/encode/django-rest-framework
- Web: https://github.com/encode/django-rest-framework/compare/3.15.1...3.15.2
- Web: https://security.snyk.io/vuln/SNYK-PYTHON-DJANGORESTFRAMEWORK-7252137
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.