8.4high
Spotipy's cache file, containing spotify auth token, is created with overly broad permissions
- Severity
- 8.4high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.83% (higher than 55% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-pwhh-q4h6-w599PYSEC-2026-1936
Description
Spotipy is a lightweight Python library for the Spotify Web API. The `CacheHandler` class creates a cache file to store the auth token. Prior to version 2.25.1, the file created has `rw-r--r--` (644) permissions by default, when it could be locked down to `rw-------` (600) permissions. 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. Version 2.25.1 tightens the cache file permissions.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| spotipy-dev spotipy | < 2.25.1 | CVE List |
| spotipy (PyPI) | before 2.25.1 | GitHub Advisory Database, PyPA Advisory Database |
| spotipy_project spotipy | before 2.25.1 | NVD |
All scores
| GitHub_M | 8.4high CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| PyPA Advisory Database | Not scored CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.
What each source says
CVE List
Spotipy is a lightweight Python library for the Spotify Web API. The `CacheHandler` class creates a cache file to store the auth token. Prior to version 2.25.1, the file created has `rw-r--r--` (644) permissions by default, when it could be locked down to `rw-------` (600) permissions. 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. Version 2.25.1 tightens the cache file permissions.
GitHub Advisory Database
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-L98
The file created has rw-r--r-- (644) permissions by default, when it could be locked down to rw------- (600) permissions. I think 600 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:
from pathlib import Path
import spotipy
from os import getenv
def create_spotify_client(client_id: str, client_secret: str) -> spotipy.Spotify:
"""Create and return an authenticated Spotify client.
Args:
client_id: Spotify API client ID
client_secret: Spotify API client secret
Returns:
An authenticated Spotify client instance
"""
cache_path = Path.home() / ".cache" / "spotify-backup/.auth_cache"
cache_path.parent.mkdir(parents=True, exist_ok=True)
cache_handler = spotipy.cache_handler.CacheFileHandler(cache_path=str(cache_path))
client = spotipy.Spotify(
auth_manager=spotipy.oauth2.SpotifyOAuth(
client_id=client_id,
client_secret=client_secret,
redirect_uri="http://localhost:8000/callback",
cache_handler=cache_handler,
scope=[
"user-library-read",
"playlist-read-private",
"playlist-read-collaborative",
],
)
)
return client
create_spotify_client()
And then check the file permissions on the cache file that was created with:
$ ls -la ~/.cache/spotify-backup/.auth_cache`
.rw-r--r--. alichtman alichtman 562 B Thu Feb 20 02:12:33 2025 /home/alichtman/.cache/spotify-backup/.auth_cache
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:
- exfiltrate spotify likes / saved playlists
- delete your content
- modify your content w/o your permission
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).
NVD (es)
Spotipy es una librería Python liviana para la API web de Spotify. La clase `CacheHandler` crea un archivo de caché para almacenar el token de autenticación. Antes de la versión 2.25.1, el archivo creado tenía permisos `rw-r--r--` (644) de forma predeterminada, cuando podía limitarse a permisos `rw-------` (600). Esto conduce a una exposición demasiado amplia del token de autenticación de Spotify. Si un atacante puede leer este token (otro usuario en la máquina o un proceso que se ejecuta como otro usuario), se puede usar para realizar acciones administrativas en la cuenta de Spotify, según el alcance otorgado al token. La versión 2.25.1 restringe los permisos del archivo de caché.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-27154 changed 2025-02-27 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-pwhh-q4h6-w599 changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2025-27154 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-1936 changed 2026-07-07 | CC-BY-4.0 |