T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/transcribe.py:86
- Finding
- API Key Exposure Through Command-Line Arguments## Vulnerability Details **File Location**: `scripts/transcribe.py:86-94`; documented usage at `SKILL.md:41-43` **Vulnerability Type**: Credential exposure through process arguments and shell history **Risk Level**: Medium ### Vulnerable Code `scripts/transcribe.py:86-94`: ```python parser.add_argument("--api-key", "-k", help="SiliconFlow API Key (也可设置环境变量 SILICONFLOW_API_KEY)") parser.add_argument("--output", "-o", help="输出文件路径 (默认输出到 stdout)") parser.add_argument("--json", action="store_true", help="以 JSON 格式输出") args = parser.parse_args() # 获取 API Key api_key = args.api_key or os.environ.get("SILICONFLOW_API_KEY", "") if not api_key: ``` `SKILL.md:41-43`: ```bash # 指定 API Key python3 scripts/transcribe.py audio.mp3 --api-key sk-xxx ``` ### Technical Analysis The script accepts a sensitive SiliconFlow API key as a command-line argument, and the documentation explicitly recommends this invocation method. Command-line arguments are not an appropriate secret transport mechanism because they may be: - Recorded in shell history. - Captured by command-execution telemetry or audit logs. - Visible to sufficiently privileged local users through process inspection facilities while the command is running. - Retained in terminal session logs or automation logs. The API key is not hardcoded or intentionally transmitted anywhere other than the declared SiliconFlow API endpoint. Nevertheless, accepting and documenting command-line secret input unnecessarily increases credential exposure. The already-supported `SILICONFLOW_API_KEY` environment variable is safer than the documented argument, although protected credential storage or an interactive secret prompt would be preferable. ### Attack Path 1. A user follows the documented example and invokes the script with `--api-key sk-xxx`. 2. The complete command is stored in shell history, execution telemetry, a process listing, or an automation log. 3. An ...[truncated 847 chars]
- Remediation
- ## Remediation Suggestions 1. Remove or deprecate the `--api-key` command-line option. 2. Remove the command-line API-key example from `SKILL.md`. 3. Prefer a secret supplied through a protected credential manager or configuration file with restrictive permissions. 4. If an environment variable remains supported, document that it should be set without placing the key directly in reusable shell commands. 5. Optionally use `getpass.getpass()` to request the credential interactively when no protected configuration is available. 6. If backward compatibility requires retaining `--api-key`, emit a clear warning explaining that command-line secrets may be exposed through shell history, process inspection, and logs. 7. Rotate any key that has already been placed in shared shell history, CI logs, or execution telemetry.
