VDB
Sign up
MEDIUM5.4

PYSEC-2026-926

Path traversal in spotipy

Quick fix

PYSEC-2026-926 — spotipy: upgrade to the fixed version with the command below.

pip install --upgrade 'spotipy>=2.22.1'

Details

### Summary If a malicious URI is passed to the library, the library can be tricked into performing an operation on a different API endpoint than intended.

### Details The [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.

Before 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.

My 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.

### Impact The 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.

Are you affected?

Enter the version of the package you're using.

Affected packages

PyPI/spotipy
Introduced in: 0Fixed in: 2.22.1
Fixpip install --upgrade 'spotipy>=2.22.1'

References