T09 · Insecure Skill Coding Practices
- Location
- scripts/video_subtitle.py:590
- Finding
- SenseAudio API Credential Exposure Through Terminal Output and Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:31`; `scripts/video_subtitle.py:590-615` **Vulnerability Type**: API credential disclosure through logs, shell history, and process metadata **Risk Level**: Medium ### Vulnerable Code In `SKILL.md:31`, the documented API-key check prints the complete credential: ```bash echo "SENSEAUDIO_API_KEY=$SENSEAUDIO_API_KEY" ``` In `scripts/video_subtitle.py:590-615`, the command-line interface accepts the credential as a process argument and passes it into the subtitle-generation workflow: ```python parser.add_argument("--senseaudio-api-key", type=str, default=None, help="SenseAudio API 密钥") args = parser.parse_args() if not os.path.exists(args.input): print(f"错误: 文件不存在: {args.input}") return output_dir = args.output if output_dir is None: output_dir = interactive_select_output_dir( args.input, default_subdir="subtitle_output" ) generate_subtitles( input_path=args.input, output_dir=output_dir, senseaudio_api_key=args.senseaudio_api_key, ``` ### Technical Analysis The documented environment-variable check expands and prints the complete `SENSEAUDIO_API_KEY`. Terminal output may be retained in agent transcripts, CI logs, terminal scrollback, shell-session recordings, or centralized logging systems. This unnecessarily discloses the secret when the task only requires determining whether it is configured. The `--senseaudio-api-key` option creates an additional exposure channel. Secrets supplied as command-line arguments may be saved in shell history and can be visible in process metadata while the program is running. Depending on operating-system configuration, other local users, monitoring agents, diagnostic utilities, or process collectors may be able to inspect these arguments. The API key is subsequently used as a bearer credential for the SenseAudio API. Disclosure therefore permits authentication as the affected SenseAudio account. Altho ...[truncated 1635 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the secret-printing check in `SKILL.md` with a presence-only test: ```bash if [ -n "${SENSEAUDIO_API_KEY:-}" ]; then echo "SENSEAUDIO_API_KEY is configured" else echo "SENSEAUDIO_API_KEY is not configured" fi ``` 2. Remove or deprecate `--senseaudio-api-key`. Prefer retrieving the credential from the environment or a protected configuration or secret-management facility. 3. If interactive credential entry remains supported, use `getpass.getpass()` so the secret is not echoed: ```python from getpass import getpass api_key = getpass( "Enter the SenseAudio API key: " ).strip() ``` 4. Never include the API key in status messages, exceptions, diagnostics, request dumps, or debug logs. If an identifier is needed for troubleshooting, display only a short, non-sensitive fingerprint. 5. Update `README.md`, `SKILL.md`, and `USAGE.md` to warn users not to place credentials directly in command-line arguments. 6. Rotate any API key that has already been printed in logs, included in shell history, or supplied through the command-line option. Remove historical copies from logs and shell history where feasible. 7. Explicitly disclose that audio is uploaded to `https://api.senseaudio.cn` for cloud transcription so users can make an informed decision before sensitive media is transmitted. ]]>
