CVE-2022-35920: Sanic Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-8cw9-5hmv-77w6
CVSS 8.3
CWE-22
Published
Advisory Summary

CVE-2022-35920 is a HIGH (CVSS 8.3) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Sanic libraries in the PyPI ecosystem. The issue involves sanic vulnerable to path traversal when using `app.static` if using encoded `%2f` urls. Remediation is available by upgrading affected packages to version 22.6.1, 21.12.2, 20.12.7.

CVE-2022-35920 at a Glance

CVE Identifier CVE-2022-35920
GHSA Identifier GHSA-8cw9-5hmv-77w6
Severity HIGH
CVSS v3.1 Base Score 8.3
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Sanic
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.3

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:N/S:C/C:L/I:L/A:L).

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

How to Fix CVE-2022-35920

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

sanic fixed: 22.6.1
pip install sanic>=22.6.1
sanic fixed: 21.12.2
pip install sanic>=21.12.2
sanic fixed: 20.12.7
pip install sanic>=20.12.7
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 sanic

How to Check if You Are Affected

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

pip show sanic

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

Note: The pip show sanic 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 Sanic, 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

### Impact Access to lateral directories when using `app.static` if using encoded `%2F` URLs. Parent directory traversal is not impacted. ### Patches - v20.12.7 (LTS) - v21.12.2 (LTS) - v22.6.1 ### References https://github.com/sanic-org/sanic/issues/2478 https://github.com/sanic-org/sanic/pull/2495 ### For more information If you have any questions or comments about this advisory: * Open an issue in [the community forums](https://community.sanicframework.org/) * Ping us on [the Discord server](https://discord.gg/FARQzAEMAA)

CVE-2022-35920 Affected Sanic Versions

3 component(s)
Fixed Versions:
22.6.121.12.220.12.7
Product / Package Ecosystem Affected Versions Fixed Version
sanic
PyPI
≥ 22.0.0
< 22.6.1
22.6.1
sanic
PyPI
≥ 21.0.0
< 21.12.2
21.12.2
sanic
PyPI
< 20.12.7
20.12.7

References

Frequently Asked Questions

What is CVE-2022-35920?
CVE-2022-35920 is a security vulnerability in Sanic involving sanic vulnerable to Path Traversal when using `app.static` if using encoded `%2F` URLs under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Sanic versions are affected?
Affected versions include releases prior to 22.6.1, 21.12.2, 20.12.7 across affected packages: sanic.
What version fixes CVE-2022-35920?
Upgrading to 22.6.1, 21.12.2, 20.12.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sanic affected?
Yes, sanic is affected in releases prior to 22.6.1, 21.12.2, 20.12.7. Upgrade your dependency to 22.6.1, 21.12.2, 20.12.7 or later.
What is the CVSS score of CVE-2022-35920?
CVE-2022-35920 has a CVSS v3.1 base score of 8.3 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L.
What CWE is associated with CVE-2022-35920?
CVE-2022-35920 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 CVE-2022-35920?
Run the dependency tree command: 'pip show sanic'. 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-8cw9-5hmv-77w6",
  "modified" : "2022-08-11T20:57:49Z",
  "published" : "2022-08-06T05:21:19Z",
  "aliases" : [ "CVE-2022-35920" ],
  "summary" : "sanic vulnerable to Path Traversal when using `app.static` if using encoded `%2F` URLs",
  "details" : "### Impact\nAccess to lateral directories when using `app.static` if using encoded `%2F` URLs. Parent directory traversal is not impacted.\n\n### Patches\n- v20.12.7 (LTS)\n- v21.12.2 (LTS)\n- v22.6.1\n\n### References\nhttps://github.com/sanic-org/sanic/issues/2478\nhttps://github.com/sanic-org/sanic/pull/2495\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [the community forums](https://community.sanicframework.org/)\n* Ping us on [the Discord server](https://discord.gg/FARQzAEMAA)\n\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sanic"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "22.0.0"
      }, {
        "fixed" : "22.6.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sanic"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "21.0.0"
      }, {
        "fixed" : "21.12.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sanic"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "20.12.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sanic-org/sanic/security/advisories/GHSA-8cw9-5hmv-77w6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35920"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sanic-org/sanic/issues/2478"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sanic-org/sanic/pull/2495"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sanic-org/sanic"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-06T05:21:19Z",
    "nvd_published_at" : "2022-08-01T22:15:00Z"
  }
}