T09 · Insecure Skill Coding Practices
- Location
scripts/auth.py:86- Finding
Spotify access token disclosed through standard output
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Spotify skill is purpose-aligned, but it handles OAuth secrets and account-changing actions in ways users should review before installing.
Review this before installing if you care about Spotify account privacy. It can store reusable Spotify credentials locally, read listening history/profile data, and modify playlists. Prefer a version that uses safer secret storage or PKCE, avoids printing tokens, removes unused scopes, and asks for confirmation before playlist changes.
scripts/auth.py:86Spotify access token disclosed through standard output
scripts/auth.py:151OAuth secrets and authorization codes accepted through command-line arguments
scripts/auth.py:95Spotify OAuth flow does not validate a state parameter
scripts/auth.py:24Unused Spotify saved-library permission violates least privilege
The skill description frames this as a simple Spotify utility, but the content also instructs OAuth credential collection, token refresh, and local persistence of sensitive tokens at a fixed filesystem path. That mismatch is dangerous because users and orchestrators may authorize the skill for harmless music tasks without realizing it will collect and store credentials and access personal account data.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
parser = argparse.ArgumentParser(description="Spotify OAuth")
parser.add_argument("--client-id", help="Spotify Client ID")
parser.add_argument("--client-secret", help="Spotify Client Secret")
parser.add_argument("--refresh", action="store_true", help="Refresh access token")
parser.add_argument("--code", help="Authorization code (extracted from URL)")
parser.add_argument("--code-url", help="Full callback URL (code extracted automatically)")
args = parser.parse_args()
The skill accesses and refreshes Spotify access tokens from persistent local storage, which is sensitive credential material. While expected for OAuth-based API access, this becomes dangerous if token storage is weakly protected or if the agent can invoke account actions without clear user awareness, potentially enabling unauthorized access to profile and playlist operations.
def refresh_and_retry():
"""Refresh token and return new access token."""
try:
subprocess.run(
[sys.executable, os.path.join(SKILL_DIR, "auth.py"), "--refresh"],
The skill advertises shell, network, and file-write capable behavior but does not declare any tool scope or permission boundaries. In practice, this means an agent could invoke credential-handling scripts, write token material to disk, and make outbound API calls without explicit guardrails, increasing the chance of overbroad execution and abuse.
The skill is designed to create persistent effects across sessions by storing tokens and modifying user playlists, which introduces session-persistence and account-state risks. If invoked unexpectedly or by a compromised agent flow, actions can outlast the current interaction and continue to affect the user's account and locally stored auth state.
---
name: spotify-playlist
description: Build and manage Spotify playlists from natural language requests. Search tracks/artists/albums, create playlists, manage tracks, view listening history. Use when the user asks to create a playlist, find music, check what they've been listening to, or any Spotify-related request. Examples - "make me a playlist for a rainy Sunday", "what have I been listening to lately", "find songs like Bonobo".
---
# Spotify Playlist Builder
The trigger language is broad enough to activate on nearly any Spotify-related request, not just narrow playlist-building tasks. Overbroad invocation increases the chance the skill runs in contexts where users did not intend account access, history inspection, or state-changing actions like playlist creation and track management.
The skill encourages use of top-tracks and recently-played data for personalization without clearly warning that it will access personal listening-history information. This creates a privacy risk because users may ask for a playlist and unintentionally expose behavioral data they did not expect the skill to inspect.
The script persists access tokens, refresh tokens, client ID, and client secret in a local JSON file under the user's home directory. Even with mode 0600, storing long-lived credentials on disk increases the blast radius of local compromise, accidental backup exposure, or misuse by other tools that can read the workspace, and the skill only needs Spotify access rather than permanent credential retention.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def exchange_code(code, client_id, client_secret):
auth_header = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
resp = requests.post("https://accounts.spotify.com/api/token", data={
"grant_type": "authorization_code",
"code": code,
"redirect_uri": REDIRECT_URI,
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def exchange_code(code, client_id, client_secret):
auth_header = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
resp = requests.post("https://accounts.spotify.com/api/token", data={
"grant_type": "authorization_code",
"code": code,
"redirect_uri": REDIRECT_URI,
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
def exchange_code(code, client_id, client_secret):
auth_header = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
resp = requests.post("https://accounts.spotify.com/api/token", data={
"grant_type": "authorization_code",
"code": code,
"redirect_uri": REDIRECT_URI,
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
auth_header = base64.b64encode(
f"{tokens['client_id']}:{tokens['client_secret']}".encode()
).decode()
resp = requests.post("https://accounts.spotify.com/api/token", data={
"grant_type": "refresh_token",
"refresh_token": tokens["refresh_token"],
}, headers={"Authorization": f"Basic {auth_header}"})
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
TOKEN_PATH = os.path.expanduser("~/.openclaw/workspace/config/.spotify-tokens.json")
SKILL_DIR = os.path.dirname(os.path.abspath(__file__))
API_BASE = "https://api.spotify.com/v1"
def get_token():
The script silently reads persisted OAuth tokens from disk and automatically refreshes them via auth.py, which enables account access without any runtime disclosure or consent checkpoint. In an agent-integrated environment, this can make credential use opaque to the user and facilitate broader-than-expected account actions if the skill is triggered indirectly.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def refresh_and_retry():
"""Refresh token and return new access token."""
try:
subprocess.run(
[sys.executable, os.path.join(SKILL_DIR, "auth.py"), "--refresh"],
capture_output=True, check=True
)
The api helper sends authenticated requests to Spotify and may retrieve listening history, profile, and playlist data tied to a user account, but the script provides no explicit privacy notice or minimization boundary. In a skill context, hidden transmission of account-linked data to external services can surprise users and increase privacy exposure if commands are invoked automatically.
The add and remove commands make irreversible or user-visible playlist changes immediately, with no confirmation, dry-run mode, or guardrails. In an agent setting, misinterpretation of natural-language requests or prompt-injection elsewhere could cause unintended modification or deletion of playlist contents.
The skill exposes a me command that returns profile fields including email, country, and product, even though the stated purpose is playlist building and music discovery. This expands access to account-linked personal data beyond what is necessary, increasing privacy risk if the agent invokes the command unnecessarily or surfaces the data to other components.
No suspicious patterns detected.