chore(deps): update dependency spotipy [security] #505
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
2.19.0→2.22.1==2.19.0→==2.25.2GitHub Vulnerability Alerts
CVE-2023-23608
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 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 viaspotifyApi.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.
CVE-2025-27154
Summary
The
CacheHandlerclass creates a cache file to store the auth token here: https://github.com/spotipy-dev/spotipy/blob/master/spotipy/cache_handler.py#L93-L98The file created has
rw-r--r--(644) permissions by default, when it could be locked down torw-------(600) permissions. I think600is a sensible default.Details
This leads to overly broad exposure of the spotify auth token. If this token can be read by an attacker (another user on the machine, or a process running as another user), it can be used to perform administrative actions on the Spotify account, depending on the scope granted to the token.
PoC
Run an application that uses spotipy with client creation like this:
And then check the file permissions on the cache file that was created with:
If this issue is combined with another misconfiguration, like having
o+rpermissions set on your home directory, an attacker will be able to read this file and steal this auth token.Good defense in depth would be to restrict read permissions on this cache file that contains an auth token
Impact
Potential exposure of Spotify auth token to other users with access to the machine. A worst case scenario is if the token is granted all permissions, and can be used to do any of:
If someone were to discover an RCE in Spotify that you could trigger on a machine by having a song played (or song metadata parsed or something), this auth token could maybe be used to add a song to a playlist, or control playback (allowing further exploitation).
CVE-2025-66040
Summary
XSS vulnerability in OAuth callback server allows JavaScript injection through unsanitized error parameter. Attackers can execute arbitrary JavaScript in the user's browser during OAuth authentication.
Details
Vulnerable Code:
spotipy/oauth2.pylines 1238-1274 (RequestHandler.do_GET)The Problem:
During OAuth flow, spotipy starts a local HTTP server to receive callbacks. The server reflects the
errorURL parameter directly into HTML without sanitization.Vulnerable code at line 1255:
Then embedded in HTML at line 1265:
The
errorparameter comes from URL parsing (lines 388-393) without HTML escaping, allowing script injection.Attack Flow:
http://127.0.0.1:8080http://127.0.0.1:8080/?error=<script>alert(1)</script>&state=xPoC
Simple Python Test:
Run it:
Output shows:
The Proof:
<script>alert("XSS")</script><script>alert("XSS")</script>Impact
Vulnerability Type: Cross-Site Scripting (XSS) - CWE-79
Affected Users: Anyone using spotipy's OAuth flow with localhost redirect URIs
Attack Complexity: Medium-High
Potential Impact:
CVSS 3.1 Score: 4.2 (Medium)
Recommended Fix:
Release Notes
plamere/spotipy (spotipy)
v2.22.1Compare Source
Added
Changed
with intended deprecation for IDs in v3
Fixed
v2.22.0Compare Source
Added
CODE_OF_CONDUCT.mdFixed
category_idinput for test_categorytest_categories_limit_lowandtest_categories_limit_highfoundvariable intest_artist_related_artistsis undefined if for loop never evaluates to truetest_new_releaseswhich looks up the wrong property of the JSON response object and always evaluates to truev2.21.0Compare Source
Added
marketparameter toalbumandalbumsto address (#753show_featured_artists.pyto/examples.FlaskSessionCacheHandler, a cache handler that stores the token info in a flask session.Fixed
AttributeErrorfortextattribute of theResponseobjectv2.20.0Compare Source
Added
RedisCacheHandler, a cache handler that stores the token info in Redis.client.Spotify._get_id()to remove queries if provided by error.RedisCacheHandlerto allow custom keys (instead of the defaulttoken_infokey)RedisCacheHandlerChanged
Configuration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR was generated by Mend Renovate. View the repository job log.