CVE-2020-25626: Djangorestframework Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-fx83-3ph3-9j2q
CVSS 6.1
CWE-20 CWE-79
Published
Advisory Summary

CVE-2020-25626 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-20: Improper Input Validation) affecting Djangorestframework libraries in the PyPI ecosystem. The issue involves cross-site scripting (xss) in django rest framework. Remediation is available by upgrading affected packages to version 3.11.2.

CVE-2020-25626 at a Glance

CVE Identifier CVE-2020-25626
GHSA Identifier GHSA-fx83-3ph3-9j2q
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-20: Improper Input Validation
Affected Product Djangorestframework
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2020-25626

To remediate this vulnerability, upgrade all affected Djangorestframework dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

djangorestframework fixed: 3.11.2
pip install djangorestframework>=3.11.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show djangorestframework

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2020-25626, inspect your installed packages using pip:

pip show djangorestframework

Analyze the terminal output to locate any version of Djangorestframework in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.11.2), your application is affected.

Note: The pip show djangorestframework command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Djangorestframework, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

A flaw was found in Django REST Framework versions before 3.12.0 and before 3.11.2. When using the browseable API viewer, Django REST Framework fails to properly escape certain strings that can come from user input. This allows a user who can control those strings to inject malicious <script> tags, leading to a cross-site-scripting (XSS) vulnerability.

CVE-2020-25626 Affected Djangorestframework Versions

1 component(s)
Fixed Versions:
3.11.2
Product / Package Ecosystem Affected Versions Fixed Version
djangorestframework
PyPI
< 3.11.2
3.11.2

References

Frequently Asked Questions

What is CVE-2020-25626?
CVE-2020-25626 is a security vulnerability in Djangorestframework involving Cross-site Scripting (XSS) in Django REST Framework under CWE-20: Improper Input Validation.
Which Djangorestframework versions are affected?
Affected versions include releases prior to 3.11.2 across affected packages: djangorestframework.
What version fixes CVE-2020-25626?
Upgrading to 3.11.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is djangorestframework affected?
Yes, djangorestframework is affected in releases prior to 3.11.2. Upgrade your dependency to 3.11.2 or later.
What is the CVSS score of CVE-2020-25626?
CVE-2020-25626 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2020-25626?
CVE-2020-25626 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2020-25626?
Run the dependency tree command: 'pip show djangorestframework'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-fx83-3ph3-9j2q",
  "modified" : "2024-09-20T14:56:47Z",
  "published" : "2021-03-19T21:32:47Z",
  "aliases" : [ "CVE-2020-25626" ],
  "summary" : "Cross-site Scripting (XSS) in Django REST Framework",
  "details" : "A flaw was found in Django REST Framework versions before 3.12.0 and before 3.11.2. When using the browseable API viewer, Django REST Framework fails to properly escape certain strings that can come from user input. This allows a user who can control those strings to inject malicious <script> tags, leading to a cross-site-scripting (XSS) vulnerability.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "djangorestframework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.11.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-25626"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=1878635"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-fx83-3ph3-9j2q"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/encode/django-rest-framework"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/djangorestframework/PYSEC-2020-263.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20201016-0003"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2022/dsa-5186"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-12T23:51:34Z",
    "nvd_published_at" : "2020-09-30T20:15:00Z"
  }
}