T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/auth.py:86
- Finding
- Spotify access token disclosed through standard output<![CDATA[ ## Vulnerability Details **File Location**: `scripts/auth.py:86-90` **Vulnerability Type**: Sensitive token exposure through process output **Risk Level**: Medium ### Vulnerable Code ```python save_tokens({ "access_token": new_tokens["access_token"], "refresh_token": new_tokens.get("refresh_token", tokens["refresh_token"]), }) print("Token refreshed successfully!") print(json.dumps({"access_token": new_tokens["access_token"]})) ``` ### Technical Analysis The refresh operation prints the newly issued Spotify access token to standard output. In an Agent environment, standard output may be returned to the caller, retained in execution traces, or captured by logging and orchestration systems. Although `scripts/spotify.py` captures the output when it invokes the refresh subprocess internally, `auth.py --refresh` remains directly executable. Consequently, the token can still be exposed to an Agent caller or any system that records command output. An access token is a bearer credential. Anyone who obtains it can use it without also knowing the client secret or refresh token until the access token expires or is revoked. ### Attack Path 1. A user or Agent invokes `python3 scripts/auth.py --refresh`. 2. The script reads the stored refresh token and client credentials. 3. Spotify returns a new access token. 4. The script writes the bearer token to standard output. 5. An Agent caller, command logger, execution trace collector, or other party with access to captured output obtains the token. 6. The party submits the token in an `Authorization: Bearer` header to Spotify APIs. ### Impact Assessment A disclosed access token permits API operations authorized by the token's granted OAuth scopes. In this project, those permissions include reading private playlists, modifying public and private playlists, reading recently played and top-track history, and unnecessarily reading the saved library. The token is time-limited, which c ...[truncated 92 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the access-token output entirely: ```python print("Token refreshed successfully!") ``` - Keep the refreshed token only in the protected token file. - Return a non-sensitive status value if machine-readable output is required: ```python print(json.dumps({"refreshed": True})) ``` - Ensure Agent execution logs and subprocess diagnostics redact OAuth access tokens. - Revoke and reauthorize affected Spotify credentials if tokens have already been retained in accessible logs. ]]>
