T09 · Insecure Skill Coding Practices
- Location
scripts/setup_model.py:163- Finding
Plaintext API Key Exposure Through Command-Line Arguments, Visible Input, and Program Output
- Content
View full analysis
/scripts/setup_model.py --provider deepseek --api-key sk-xxx ``` ### Technical Analysis API keys are authentication credentials and should not be exposed through process arguments, visible terminal entry, or routine output. Passing a key through `--api-key` can persist it in shell history. Depending on the operating system and process isolation settings, it may also be visible to process-monitoring utilities, diagnostic too ...[truncated 2298 chars]- Remediation
View remediation
`. - Accept the key through a protected environment variable, standard input, an inherited file descriptor, or an operating-system credential store. - If compatibility requires the option temporarily, display a prominent warning that it can expose the key through shell history and process inspection. 2. **Conceal interactive credential entry** - Replace ordinary terminal input with hidden input: ```python from getpass import getpass api_key = getpass("Enter API key: ").strip() ``` 3. **Do not print complete credentials** - Avoid emitting a patch containing the real `apiKey` to standard output. - Pass the patch directly to the trusted configuration API through an in-memory channel where supported. - If output is necessary, print a redacted representation such as `"apiKey": "********"` and provide the secret separately through a protected channel. 4. **Reduce accidental logging** - Ensure errors and debug output never include the key. - Document that generated configuration and transcripts are sensitive. - Disable or sanitize command tracing and application logging around secret processing. 5. **Update documentation** - Replace examples using `--api-key sk-xxx` with a secure workflow. - Explain the risks of shell history, process arguments, terminal scrollback, redirected output, and agent transcripts. - Do not imply that encrypted storage protects credentials before they reach the storage layer. 6. **Operational response** - Advise users who have already used the existing workflow to inspect and remove affected shell history and logs where feasible. - Rotate any API key that may have appeared in process arguments, terminal recordings, generated output, or agent transcripts. ]]>
