GHSA-6r3c-8xf3-ggrr: Django sendfile2 Path Traversal Vulnerability

MODERATE
CWE-22
Published
Advisory Summary

GHSA-6r3c-8xf3-ggrr is a MODERATE path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Django sendfile2 libraries in the PyPI ecosystem. The issue involves directory traversal outside of sendfile_root in django-sendfile2. Remediation is available by upgrading affected packages to version 0.6.0.

GHSA-6r3c-8xf3-ggrr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-6r3c-8xf3-ggrr
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Django sendfile2
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix GHSA-6r3c-8xf3-ggrr

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

django-sendfile2 fixed: 0.6.0
pip install django-sendfile2>=0.6.0
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 django-sendfile2

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-6r3c-8xf3-ggrr, inspect your installed packages using pip:

pip show django-sendfile2

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Django sendfile2, 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

django-sendfile2 currently relies on the backend to correctly limit file paths to `SENDFILE_ROOT`. This is not the case for the `simple` and `development` backends, it is also not necessarily the case for any of the other backends either (it's just an assumption that was made by the original author). This will be fixed in 0.6.0 which is to be released the same day as this advisory is made public. When upgrading, you will need to make sure `SENDFILE_ROOT` is set in your settings module if it wasn't already.

GHSA-6r3c-8xf3-ggrr Affected Django sendfile2 Versions

1 component(s)
Fixed Versions:
0.6.0
Product / Package Ecosystem Affected Versions Fixed Version
django-sendfile2
PyPI
< 0.6.0
0.6.0

References

Frequently Asked Questions

What is GHSA-6r3c-8xf3-ggrr?
GHSA-6r3c-8xf3-ggrr is a security vulnerability in Django sendfile2 involving Directory traversal outside of SENDFILE_ROOT in django-sendfile2 under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Django sendfile2 versions are affected?
Affected versions include releases prior to 0.6.0 across affected packages: django-sendfile2.
What version fixes GHSA-6r3c-8xf3-ggrr?
Upgrading to 0.6.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is django-sendfile2 affected?
Yes, django-sendfile2 is affected in releases prior to 0.6.0. Upgrade your dependency to 0.6.0 or later.
What CWE is associated with GHSA-6r3c-8xf3-ggrr?
GHSA-6r3c-8xf3-ggrr is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for GHSA-6r3c-8xf3-ggrr?
Run the dependency tree command: 'pip show django-sendfile2'. 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-6r3c-8xf3-ggrr",
  "modified" : "2021-09-22T18:37:22Z",
  "published" : "2020-06-24T17:15:26Z",
  "aliases" : [ ],
  "summary" : "Directory traversal outside of SENDFILE_ROOT in django-sendfile2",
  "details" : "django-sendfile2 currently relies on the backend to correctly limit file paths to `SENDFILE_ROOT`. This is not the case for the `simple` and `development` backends, it is also not necessarily the case for any of the other backends either (it's just an assumption that was made by the original author).\n\nThis will be fixed in 0.6.0 which is to be released the same day as this advisory is made public.\n\nWhen upgrading, you will need to make sure `SENDFILE_ROOT` is set in your settings module if it wasn't already.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "django-sendfile2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.6.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/moggers87/django-sendfile2/security/advisories/GHSA-6r3c-8xf3-ggrr"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/moggers87/django-sendfile2/commit/f870c52398a55b9b5189932dd8caa24efb4bc1e1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/moggers87/django-sendfile2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-06-18T16:55:25Z",
    "nvd_published_at" : null
  }
}