CVE-2022-35920: Sanic Path Traversal Vulnerability
HIGHCVE-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
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).
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.
pip install sanic>=22.6.1
pip install sanic>=21.12.2
pip install sanic>=20.12.7
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
CVE-2022-35920 Affected Sanic Versions
3 component(s)| 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?
Which Sanic versions are affected?
What version fixes CVE-2022-35920?
Is sanic affected?
What is the CVSS score of CVE-2022-35920?
What CWE is associated with CVE-2022-35920?
How can I check PyPI dependencies for CVE-2022-35920?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}