T09 · Insecure Skill Coding Practices
- Location
scripts/suno_api.py:28- Finding
Bearer Credential Disclosure Through an Unrestricted Custom API Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/suno_api.py, lines 28-43
Vulnerability Type: Unrestricted credential forwarding to a configurable network destination
Risk Level: HighVulnerable Code
python BASE_URL = os.getenv("SUNO_BASE_URL", "https://api.sunoapi.org") API_KEY = os.getenv("SUNO_API_KEY", "") VALID_MODELS = ["V4", "V4_5", "V4_5ALL", "V4_5PLUS", "V5", "V5_5"] def _headers() -> dict: h = {"Content-Type": "application/json"} if API_KEY: h["Authorization"] = f"Bearer {API_KEY}" return h def _post(path: str, data: dict) -> dict: r = requests.post(f"{BASE_URL}{path}", headers=_headers(), json=data, timeout=120) r.raise_for_status() return r.json() def _get(path: str, params: dict = None) -> dict: r = requests.get(f"{BASE_URL}{path}", headers=_headers(), params=params, timeout=30) r.raise_for_status() return r.json()Technical Analysis
The API destination is taken directly from the
SUNO_BASE_URLenvironment variable without validating its scheme or hostname. Both_post()and_get()unconditionally use_headers(), which adds theSUNO_API_KEYvalue as a bearer credential whenever the variable is populated.Consequently, changing
SUNO_BASE_URLcauses the Suno credential to be forwarded to the selected destination. There is no restriction tohttps://api.sunoapi.org, no HTTPS-only policy, no trusted-host allowlist, and no separation between the credential for the official service and credentials intended for custom endpoints.Although custom endpoint support is documented, transmitting the official API credential to any configured host is not necessary to support that feature safely. A custom endpoint could instead use a separate credential or require explicit authorization before credential forwarding.
Attack Path
- An attacker, malicious wrapper, compromised execution environment, or unsafe conf ...[truncated 1256 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
SUNO_BASE_URLto use HTTPS and reject URLs containing unexpected schemes, user information, fragments, or malformed hostnames. - Maintain an explicit allowlist for endpoints that may receive
SUNO_API_KEY, withapi.sunoapi.orgas the default trusted host. - Do not forward the official Suno bearer token to a custom host automatically.
- Introduce a separate variable such as
SUNO_CUSTOM_API_KEYfor custom endpoints. - If credential forwarding to a non-default endpoint is required, require an explicit opt-in flag and display the destination hostname before transmission.
- Resolve redirects carefully and prevent authorization headers from being retained when a redirect crosses origins.
- Fail closed when URL validation fails, and avoid including credentials or sensitive response content in error output.
- Require
