---
id: CVE-2024-21520
aliases:
  - GHSA-gw84-84pc-xp82
  - PYSEC-2026-1304
title: Cross-site Scripting in djangorestframework
summary: Cross-site Scripting in djangorestframework
severity: medium
cvss: 6.1
cvssVector: 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N'
vendor: djangorestframework
product: djangorestframework
ecosystem: pip
affected:
  - djangorestframework < 3.15.2
patched:
  - djangorestframework 3.15.2
published: '2024-06-26'
updated: '2026-07-07'
source: OSV
sourceUrl: 'https://osv.dev/vulnerability/GHSA-gw84-84pc-xp82'
references:
  - url: 'https://nvd.nist.gov/vuln/detail/CVE-2024-21520'
  - url: 'https://github.com/encode/django-rest-framework/pull/9435'
  - url: >-
      https://github.com/encode/django-rest-framework/commit/3b41f0124194430da957b119712978fa2266b642
  - url: 'https://github.com/encode/django-rest-framework'
  - url: 'https://github.com/encode/django-rest-framework/compare/3.15.1...3.15.2'
  - url: 'https://security.snyk.io/vuln/SNYK-PYTHON-DJANGORESTFRAMEWORK-7252137'
tags:
  - osv
  - pip
  - exploit-available
epss: 0.01133
epssPercentile: 0.65062
ingestedAt: '2026-07-08T18:25:49.952Z'
exploits:
  github: 1
  githubRepos:
    - 'https://github.com/ch4n3-yoon/CVE-2024-21520-Demo'
  checkedAt: '2026-09-26T09:05:30.840Z'
exploitAvailable: true
---

## Overview

Versions of the package djangorestframework before 3.15.2 are vulnerable to Cross-site Scripting (XSS) via the break_long_headers template filter due to improper input sanitization before splitting and joining with <br> tags.

## Affected packages

- `djangorestframework < 3.15.2`

## Remediation

Upgrade to a patched release:

- `djangorestframework 3.15.2`
