T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/tts.py:18
- Finding
- Hard-Coded MiniMax API Credential<![CDATA[ ## Vulnerability Details **File Location**: `scripts/tts.py`, lines 18–21 **Vulnerability Type**: Hard-coded secret / exposed API credential **Risk Level**: High ### Vulnerable Code ```python def get_api_key(): """获取 API Key""" key = "sk-api-[REDACTED]" return key ``` The complete credential value has been redacted from this report to prevent further disclosure. In the audited source, the full bearer token is stored directly in the `key` string. ### Technical Analysis The script embeds a MiniMax API credential directly in its source code. The returned value is subsequently inserted into the `Authorization: Bearer` header for requests to the following endpoints: - `https://api.minimaxi.com/v1/get_voice` - `https://api.minimaxi.com/v1/t2a_v2` Source code is not an appropriate secret-storage boundary. Anyone who can download, inspect, copy, or access the Skill package can recover the credential without authentication. Removing the credential in a later revision would also be insufficient if it remains available in repository history, cached packages, logs, or previous distributions. The network requests themselves are consistent with the declared cloud text-to-speech functionality: user-supplied text must be sent to MiniMax to synthesize speech, and voice enumeration requires an account API call. The vulnerability is therefore not the necessary provider communication, but the distribution of a shared account credential with the Skill. ### Attack Path 1. An attacker obtains the Skill package or reads `scripts/tts.py`. 2. The attacker extracts the hard-coded token from `get_api_key()`. 3. The attacker constructs requests using the extracted token as a MiniMax bearer credential. 4. The attacker invokes API operations permitted to the associated account, including speech synthesis and account-scoped voice enumeration. 5. The attacker repeatedly consumes the account's quota or paid API capacity until the credential is revoked, potentially ...[truncated 1005 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Revoke and rotate the exposed credential immediately.** Treat it as compromised because it was distributed in source code. 2. **Remove the credential from the current source and repository history.** Purge it from prior commits, release archives, package caches, build artifacts, examples, and logs where feasible. 3. **Load credentials from a protected runtime source**, such as an environment variable or operating-system secret store: ```python def get_api_key(): key = os.environ.get("MINIMAX_API_KEY") if not key: raise RuntimeError( "MINIMAX_API_KEY is required. Configure it through a protected secret store." ) return key ``` 4. **Require each user or deployment to supply its own credential.** Do not distribute a shared provider account token with the Skill. 5. **Apply provider-side least privilege.** Restrict the replacement key to only the MiniMax operations required for voice enumeration and text-to-speech, if MiniMax supports granular scopes. 6. **Add secret-scanning controls** to pre-commit hooks and CI pipelines to reject API tokens before publication. 7. **Monitor the affected account** for unauthorized requests, unexpected voice enumeration, quota consumption, or charges associated with the exposed key. 8. **Document the external data flow clearly.** Inform users that text submitted for synthesis is transmitted to MiniMax and may be processed according to the provider's retention and privacy policies. ]]>
