T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/minimax_tts.py:104
- Finding
- MiniMax API Credential Disclosure Through Unrestricted Endpoint Overrides<![CDATA[ ## Vulnerability Details **File Location**: `scripts/minimax_tts.py:104-107, 130, 150-156, 219-220, 231-232` **Vulnerability Type**: Bearer-token disclosure to a user-controlled network destination **Risk Level**: High ### Vulnerable Code ```python def run_tts(args: argparse.Namespace) -> None: api_key = ensure_api_key() headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", } ``` ```python response = requests.post( args.endpoint, headers=headers, json=payload, timeout=args.timeout, ) ``` ```python def run_voices(args: argparse.Namespace) -> None: api_key = ensure_api_key() headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", } payload = {"voice_type": args.voice_type} try: response = requests.post( args.endpoint, headers=headers, json=payload, timeout=args.timeout, ) ``` ```python tts_parser.add_argument( "--endpoint", default="https://api.minimax.io/v1/t2a_v2", help="Override MiniMax T2A endpoint", ) ``` ```python voices_parser.add_argument( "--endpoint", default="https://api.minimax.io/v1/get_voice", help="Override the catalog endpoint", ) ``` ### Technical Analysis Both CLI subcommands accept an unrestricted `--endpoint` argument. The script then attaches the value of `MINIMAX_API_KEY` as an HTTP bearer token to a request sent to that destination. Sending the credential to the default official MiniMax endpoints is necessary for the declared functionality. Allowing any caller-controlled host to receive the same credential is not necessary and violates least-privilege network handling. The code does not enforce HTTPS, validate the hostname, constrain the URL path, or require confirmation before sending the credential to a non-default destination. Consequently, an untrusted command, copied usage instruction, or ac ...[truncated 1369 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace unrestricted endpoint overrides with an allowlist of exact HTTPS origins, such as the documented MiniMax regional API hosts. 2. Validate all of the following before constructing or sending an authenticated request: - Scheme must be `https`. - Hostname must exactly match an approved MiniMax domain. - Port must be the expected HTTPS port. - URL must not contain embedded credentials. - Path must match the endpoint expected by the selected subcommand. 3. Do not attach `MINIMAX_API_KEY` when the destination is outside the allowlist. 4. If custom endpoints are an essential advanced feature, require an explicit unsafe-mode option and a separate credential intended for that endpoint. Display the normalized destination before transmission. 5. Ensure redirects are disabled or revalidated so an approved endpoint cannot redirect an authenticated request to an unapproved host. 6. Add automated tests confirming that HTTP URLs, lookalike domains, subdomain tricks, IP literals, and unknown paths are rejected. ]]>
