T09 · Insecure Skill Coding Practices
- Location
scripts/generate.js:3- Finding
Unrestricted API Base Override Can Exfiltrate API Credentials During Music Generation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.js, lines 3-4 and 21-34
Vulnerability Type: Unvalidated destination for authenticated network requests
Risk Level: HighVulnerable Code
js const API_BASE = process.env.MBM_API_BASE || "https://api.makebestmusic.com"; const API_KEY = process.env.apiKey;js const res = await fetch(`${API_BASE}/api/skill/generate_music`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${API_KEY}`, }, body: JSON.stringify({ model: "Fi", custom: true, instrumental: instrumental, prompt: prompt, title: "", style: "", advance: { vocal_gender: "", ai_lyrics: true } }), });Technical Analysis
The script permits the destination of an authenticated request to be replaced through the
MBM_API_BASEenvironment variable. This variable is not documented as a required or supported configuration option inSKILL.md, and the code does not validate its scheme, hostname, port, or origin.Under normal operation, sending the API key and music prompt to the declared MakeBestMusic HTTPS endpoint is necessary for the Skill's stated music-generation functionality. However, allowing an unrestricted endpoint override is not necessary for that functionality and violates least privilege. If an attacker or compromised launcher can influence the process environment, the bearer credential and user-supplied prompt will be sent to an attacker-controlled server.
This is a destination-validation flaw rather than proof of intentional exfiltration: the default destination is the documented MakeBestMusic service. Exploitation requires influence over the script's environment.
Attack Path
- An attacker gains the ability to set or alter environment variables used when the Skill process starts.
- The attacker sets
MBM_API_BASEto an attacker ...[truncated 1057 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
MBM_API_BASEoverride from production code and use a fixed HTTPS origin:js const API_BASE = "https://api.makebestmusic.com"; - If endpoint overrides are required for development or testing, enable them only under an explicit development mode.
- Parse the configured URL with
new URL()and enforce:https:protocol.- An exact hostname allowlist.
- Approved ports only.
- No embedded credentials.
- Reject configuration that does not match the approved MakeBestMusic origin before reading or transmitting the API key.
- Use narrowly scoped and short-lived API credentials where supported.
- Avoid placing unnecessary user data in outbound requests and clearly document what information is transmitted.
- Add automated tests confirming that unapproved origins cannot receive authenticated requests.
- Remove the
