GHSA-q764-g6fm-555v

Suggest an improvement
Source
https://github.com/advisories/GHSA-q764-g6fm-555v
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2023/01/GHSA-q764-g6fm-555v/GHSA-q764-g6fm-555v.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-q764-g6fm-555v
Aliases
Published
2023-01-23T22:05:11Z
Modified
2023-11-08T04:11:40.872655Z
Severity
  • 5.4 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L CVSS Calculator
Summary
Path traversal in spotipy
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 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.

References

Affected packages

PyPI / spotipy

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
2.22.1

Affected versions

0.*

0.1
0.2

2.*

2.0.1
2.0.2
2.1.0
2.2.0
2.3.0
2.3.2
2.3.3
2.3.4
2.3.5
2.3.6
2.3.7
2.3.8
2.4.0
2.4.1
2.4.2
2.4.3
2.4.4
2.5.0
2.6.0
2.6.1
2.6.2
2.6.3
2.7.0
2.7.1
2.8.0
2.9.0
2.10.0
2.11.0
2.11.1
2.11.2
2.12.0
2.13.0
2.14.0
2.15.0
2.16.0
2.16.1
2.17.0
2.17.1
2.18.0
2.19.0rc1
2.19.0
2.20.0
2.21.0
2.22.0