fix(deps): update dependency spotipy [security] #423
+169
−51
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.1
GitHub 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
CacheHandler
class 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 think600
is 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+r
permissions 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).
Release Notes
plamere/spotipy (spotipy)
v2.22.1
Compare Source
Added
Changed
with intended deprecation for IDs in v3
Fixed
v2.22.0
Compare Source
Added
CODE_OF_CONDUCT.md
Fixed
category_id
input for test_categorytest_categories_limit_low
andtest_categories_limit_high
found
variable intest_artist_related_artists
is undefined if for loop never evaluates to truetest_new_releases
which looks up the wrong property of the JSON response object and always evaluates to truev2.21.0
Compare Source
Added
market
parameter toalbum
andalbums
to address (#753show_featured_artists.py
to/examples
.FlaskSessionCacheHandler
, a cache handler that stores the token info in a flask session.Fixed
AttributeError
fortext
attribute of theResponse
objectv2.20.0
Compare Source
Added
RedisCacheHandler
, a cache handler that stores the token info in Redis.client.Spotify._get_id()
to remove queries if provided by error.RedisCacheHandler
to allow custom keys (instead of the defaulttoken_info
key)RedisCacheHandler
Changed
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.