CVE-2023-23608: Spotipy Path Traversal Vulnerability
MODERATECVE-2023-23608 is a MODERATE (CVSS 5.4) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Spotipy libraries in the PyPI ecosystem. The issue involves path traversal in spotipy. Remediation is available by upgrading affected packages to version 2.22.1.
CVE-2023-23608 at a Glance
Security Impact
CVSS: 5.4
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:U/C:N/I:L/A:L).
How to Fix CVE-2023-23608
To remediate this vulnerability, upgrade all affected Spotipy 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 spotipy>=2.22.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show spotipy
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2023-23608, inspect your installed packages using pip:
pip show spotipy
Analyze the terminal output to locate any version of Spotipy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.22.1), your application is affected.
Note: The pip show spotipy 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 Spotipy, 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-2023-23608 Affected Spotipy Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
spotipy
|
PyPI |
< 2.22.1
|
2.22.1
|
References
Frequently Asked Questions
What is CVE-2023-23608?
Which Spotipy versions are affected?
What version fixes CVE-2023-23608?
Is spotipy affected?
What is the CVSS score of CVE-2023-23608?
What CWE is associated with CVE-2023-23608?
How can I check PyPI dependencies for CVE-2023-23608?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-q764-g6fm-555v",
"modified" : "2023-02-07T04:11:52Z",
"published" : "2023-01-23T22:05:11Z",
"aliases" : [ "CVE-2023-23608" ],
"summary" : "Path traversal in spotipy",
"details" : "### Summary\nIf a malicious URI is passed to the library, the library can be tricked into performing an operation on a different API endpoint than intended.\n\n### Details\nThe [code Spotipy uses to parse URIs and URLs ](https://github.com/spotipy-dev/spotipy/blob/master/spotipy/client.py#L1942) accepts user data too liberally which allows a malicious user to insert arbitrary characters into the path that is used for API requests. Because it is possible to include `..`, an attacker can redirect for example a track lookup via `spotifyApi.track()` to an arbitrary API endpoint like playlists, but this is possible for other endpoints as well.\n\nBefore the security advisory feature was enabled on GitHub, I was already in contact with Stéphane Bruckert via e-mail, and he asked me to look into a potential fix. \n\nMy recommendation is to perform stricter parsing of URLs and URIs, which I implemented in the patch included at the end of the report. If you prefer, I can also invite you to a private fork of the repository.\n\n### Impact\nThe impact of this vulnerability depends heavily on what operations a client application performs when it handles a URI from a user and how it uses the responses it receives from the API.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "spotipy"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.22.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/spotipy-dev/spotipy/security/advisories/GHSA-q764-g6fm-555v"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-23608"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/spotipy-dev/spotipy"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-01-23T22:05:11Z",
"nvd_published_at" : "2023-01-26T21:18:00Z"
}
}