T09 · Insecure Skill Coding Practices
- Location
scripts/spotify-auth.py:24- Finding
OAuth Authorization Flow Does Not Validate the State Parameter
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is not clearly malicious, but it grants and stores Spotify account access more broadly than its music-history purpose requires.
Review before installing. Use it only on a trusted machine, grant the minimum Spotify scopes needed, avoid the raw `json` endpoint unless you understand what it can read, and treat the stored token as sensitive account access.
scripts/spotify-auth.py:24OAuth Authorization Flow Does Not Validate the State Parameter
scripts/spotify-auth.py:15OAuth Scopes Exceed the Skill's Implemented Functional Requirements
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
}
)
with urllib.request.urlopen(req) as resp:
new_data = json.load(resp)
# Keep refresh token if not returned
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
}
)
with urllib.request.urlopen(req) as resp:
new_data = json.load(resp)
# Keep refresh token if not returned
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
}
)
with urllib.request.urlopen(req) as resp:
new_data = json.load(resp)
# Keep refresh token if not returned
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
}
)
with urllib.request.urlopen(req) as resp:
return json.load(resp)
def save_token(token_data):
The declared purpose is limited to listening history, top items, and recommendations, but the documented json command allows arbitrary Spotify Web API endpoint access. That broader behavior can expose additional account data or actions beyond user expectations, violating least privilege and making misuse easier.
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
rm ~/.config/spotify-clawd/token.json
python3 scripts/spotify-auth.py
The README advertises access to listening history, top artists, and recommendations but does not warn that these are privacy-sensitive data tied to a personal account. Because music history can reveal habits, preferences, routines, or potentially sensitive interests, missing disclosure increases the risk of uninformed consent and inappropriate handling of personal data.
The activation examples are open-ended and encourage the agent to fetch and analyze a user's Spotify data without clear limits on when access should occur. In a skill that processes personal listening history, broad triggers can lead to over-collection or use of sensitive preference data in situations where the user did not clearly consent to that specific access.
The skill documents capabilities that involve shell execution, file reads/writes, environment access, and network access, but it does not declare any explicit tool scope or permission boundaries. This increases the chance an agent will invoke the skill with broader privileges than users expect, especially because the workflow handles secrets and OAuth tokens.
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
### Manual Setup
1. **Create Spotify Developer App**
- Go to [developer.spotify.com/dashboard](https://developer.spotify.com/dashboard)
- Click **Create App**
- Fill in:
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
"client_secret": "your_client_secret" } EOF chmod 600 credentials/spotify.json
**Option B: Environment variables**
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Option B: Environment variables
# Add to ~/.zshrc or ~/.bashrc
export SPOTIFY_CLIENT_ID="your_client_id"
export SPOTIFY_CLIENT_SECRET="your_client_secret"
Advertising a narrowly focused history/recommendation skill while exposing a raw endpoint interface is a scope discrepancy that can enable access to data not implied by the description. In agent settings, this is dangerous because downstream users may authorize or trust the skill based on a much narrower understanding of its behavior.
The script collects the Spotify client secret using a normal read -p, which echoes the secret to the terminal and may expose it to shoulder surfing, screen recording, terminal logging, or shared-session capture. In a setup script specifically handling API credentials, this is a real confidentiality weakness even though it affects developer credentials rather than arbitrary code execution.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
}
EOF
chmod 600 "$CREDS_FILE"
echo "✓ Credentials saved to: $CREDS_FILE"
echo
This code makes authenticated HTTP requests to Spotify endpoints that retrieve personal listening data such as recently played tracks, top artists, and top tracks. While the module docstring describes functionality, there is no explicit warning, confirmation, or user-facing disclosure that personal account data will be sent to and fetched from Spotify services.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
return new_data
def api_request(endpoint, token_data, params=None):
url = f"https://api.spotify.com/v1{endpoint}"
if params:
url += "?" + urllib.parse.urlencode(params)
The json command exposes arbitrary Spotify API endpoint access, which exceeds the stated skill scope of listening history, top items, and recommendations. In an agent setting, this broadens the accessible data surface to additional profile, library, device, or account endpoints that the user may not expect this skill to query.
Allowing arbitrary endpoint querying is unjustified for the declared purpose of listening-history analytics and recommendations. This overbroad capability can be abused by downstream prompts or agents to retrieve unrelated user data from Spotify using the same OAuth token, violating least privilege and increasing privacy risk.
No suspicious patterns detected.