T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/mimo_tts.py:81
- Finding
- API Key Exposure Through Command-Line Arguments## Vulnerability Details **File Location**: `scripts/mimo_tts.py`, lines 81-87 **Vulnerability Type**: API credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```python parser.add_argument("--api-key", "-k", default=None, help="API密钥 (也可通过 MIMO_API_KEY 环境变量设置)") args = parser.parse_args() if args.api_key: os.environ["MIMO_API_KEY"] = args.api_key ``` ### Technical Analysis The script accepts the MiMo API key through the `--api-key` command-line option. Command-line arguments are not an appropriate channel for sensitive credentials because they may be exposed through: - Process listings and process-monitoring interfaces while the command is running. - Shell command history. - System audit or endpoint-monitoring logs. - Job schedulers, diagnostic reports, and command-execution telemetry. - Wrapper scripts or automation configuration containing the full command. Assigning the supplied value to `os.environ` does not remove it from the original argument vector. It also creates an additional in-process copy that may be inherited by child processes if the script is later extended to launch them. ### Attack Path 1. A user invokes the script with a command such as `python3 scripts/mimo_tts.py "text" --api-key SECRET`. 2. The secret becomes part of the process argument vector and may also be recorded in shell history or operational logs. 3. A local user, monitoring service, log reader, or other principal with access to this metadata retrieves the key. 4. The attacker submits unauthorized requests to the Xiaomi MiMo API using the exposed credential. 5. The attacker consumes the associated quota or performs API operations permitted by the compromised key until it is revoked. Exploitation requires access to process metadata, command history, automation configuration, or logs containing the invocation. No remote code-execution path was identified. ...[truncated 534 chars]
- Remediation
- ## Remediation Suggestions - Remove the `--api-key` and `-k` command-line options. - Prefer the existing `MIMO_API_KEY` environment-variable mechanism when the execution environment can protect environment values. - For interactive use, obtain the credential through `getpass.getpass()` so it is not echoed or stored in shell history. - For production use, retrieve the key from a dedicated secret manager or a permission-restricted configuration file. - If the local configuration fallback remains supported, verify that the configuration file is owned by the expected user and reject files with overly permissive access modes. - Avoid copying credentials between storage mechanisms unless necessary, and never print credentials in errors or diagnostic output. - Document credential rotation procedures and advise users who previously used `--api-key` to clear relevant shell history and logs and rotate potentially exposed keys.
