T09 · Insecure Skill Coding Practices
- Location
scripts/clone.py:44- Finding
Unvalidated MiniMax API Base Can Redirect Credentials, Text, and Voice Samples
- Content
View full analysis
Vulnerability Details
File Location:
scripts/clone.py:44, 97-137;scripts/backends/minimax.py:32-35, 69
Vulnerability Type: Arbitrary credential-bearing endpoint override
Risk Level: HighThe
MINIMAX_API_BASEenvironment variable is used without validating its scheme, hostname, port, or destination. Requests sent to the resulting URL include the MiniMax bearer credential and sensitive user content.Vulnerable Code
From
scripts/clone.py:python MINIMAX_BASE = os.environ.get( "MINIMAX_API_BASE", "https://api.minimax.io/v1" )python api_key = os.environ.get("MINIMAX_API_KEY") if not api_key: raise SystemExit(emit_error( "auth_missing_env", "MINIMAX_API_KEY not set", backend="minimax", exit_code=EXIT_AUTH)) headers = {"Authorization": f"Bearer {api_key}"} # Reference audio: local file preferred; URLs are downloaded first. if re.match(r"https?://", audio): resp = requests.get(audio, timeout=120) resp.raise_for_status() content = resp.content filename = os.path.basename(audio.split("?")[0]) or "sample.wav" else: if not os.path.isfile(audio): raise SystemExit(emit_error( "input_not_found", f"Audio file not found: {audio}", field="audio", exit_code=EXIT_VALIDATION)) with open(audio, "rb") as f: content = f.read() filename = os.path.basename(audio) print(" Uploading reference audio ...", file=sys.stderr) r = requests.post( f"{MINIMAX_BASE}/files/upload", headers=headers, data={"purpose": "voice_clone"}, files={"file": (filename, content)}, timeout=300, )python r = requests.post( f"{MINIMAX_BASE}/voice_clone", headers={**headers, "Content-Type": "application/json"}, json={"file_id": file_id, "voice_id": vid}, timeout=300, )From
scripts/backends/minimax.py:python # Global site by ...[truncated 2684 chars]- Remediation
View remediation
Remediation Suggestions
- Parse
MINIMAX_API_BASEwithurllib.parse.urlparse. - Require the
httpsscheme. - Allowlist the documented MiniMax hosts, such as the approved global and China API domains.
- Reject embedded user information, fragments, unexpected ports, IP-literal destinations, and hostnames outside the allowlist.
- Keep separate constants for the approved global and China endpoints and expose a constrained region selector instead of accepting an arbitrary URL.
- If custom endpoints are necessary for development, require an explicit unsafe-development option and display the exact destination before transmitting credentials or voice samples.
- Do not attach production credentials to custom endpoints by default.
- Add automated tests covering HTTP URLs, lookalike domains, subdomain confusion, user-information syntax, redirects, and unexpected ports.
- Consider disabling redirects for credential-bearing uploads or verify every redirect destination before forwarding authorization headers.
- Parse
