T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/utils.py:13
- Finding
- Unvalidated API Base URL Can Exfiltrate Credentials and Sensitive User Content<![CDATA[ ## Vulnerability Details **File Location**: `scripts/utils.py:13-15, 160-181`; related sinks in `scripts/sync_tts.py:149-173` and `scripts/voice_clone.py:78-96, 132-150` **Vulnerability Type**: Unrestricted credential-bearing network destination **Risk Level**: High ### Complete Code Snippet From `scripts/utils.py`: ```python # API Configuration MINIMAX_VOICE_API_KEY = os.getenv("MINIMAX_VOICE_API_KEY") MINIMAX_API_BASE = os.getenv("MINIMAX_API_BASE", "https://api.minimaxi.com/v1") MINIMAX_API_BASE_BACKUP = "https://api-bj.minimaxi.com/v1" def make_request( method: str, endpoint: str, data: Optional[Dict] = None, files: Optional[Dict] = None, params: Optional[Dict] = None, timeout: int = 120, use_backup: bool = False ) -> Dict[str, Any]: base_url = MINIMAX_API_BASE_BACKUP if use_backup else MINIMAX_API_BASE url = f"{base_url}/{endpoint.lstrip('/')}" if files: headers = { "Authorization": f"Bearer {MINIMAX_VOICE_API_KEY}", "Accept-Encoding": "gzip, deflate", } else: headers = get_headers() response = requests.request( method=method, url=url, headers=headers, json=data if not files else None, data=data if files else None, files=files, params=params, timeout=timeout, ) response.raise_for_status() return response.json() ``` Related TTS sink in `scripts/sync_tts.py`: ```python headers = get_headers() url = f"{MINIMAX_API_BASE}/t2a_v2" with requests.post( url, headers=headers, json=payload, stream=True, timeout=300 ) as response: response.raise_for_status() ``` Related biometric audio upload sink in `scripts/voice_clone.py`: ```python import requests url = f"{MINIMAX_API_BASE}/files/upload" headers = {"Authorization": f"Bearer {MINIMAX_VOICE_API_KEY}"} with open(file_path, "rb") as f: files = {"file": (os.path.basename(file_path), f)} ...[truncated 2923 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Use a fixed official HTTPS origin unless custom endpoints are an explicitly required feature: ```python MINIMAX_API_BASE = "https://api.minimaxi.com/v1" ``` 2. If endpoint customization is required, validate the parsed URL before sending any credential: - Require `https`. - Reject embedded credentials. - Require an approved normalized hostname. - Restrict ports to approved values. - Reject fragments and unexpected path prefixes. - Resolve and compare the final destination against an explicit allowlist. 3. Disable automatic cross-origin redirects for authenticated requests, or manually verify every redirect target before resending the authorization header. 4. Separate endpoint configuration from credential handling. Only attach the bearer token after confirming that the final origin is trusted. 5. Add tests proving that HTTP URLs, unapproved domains, crafted subdomains, user-information components, and cross-origin redirects are rejected. 6. Clearly disclose in the user-facing documentation that TTS text and voice-cloning recordings are transmitted to MiniMax. For biometric voice data, require explicit user intent and recommend obtaining the speaker's consent. ]]>
