T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/fetch_astock_accounts.py:13
- Finding
- API Key Exposure Through Command-Line Arguments and Insecure Plaintext Configuration<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:42-43`, `scripts/fetch_astock_accounts.py:13,54-57,224,231`, `scripts/fetch_subscribed_updates.py:13,48-50,202,207` **Vulnerability Type**: API credential disclosure through process arguments, shell history, and insufficiently protected plaintext storage **Risk Level**: Medium ### Vulnerable Code Snippets `scripts/fetch_astock_accounts.py:13` ```python python3 fetch_astock_accounts.py --date 2026-06-15 --api-key ak_xxx ``` `scripts/fetch_astock_accounts.py:54-57` ```python def get_api_key(cli_key=None): """Get API key: CLI arg > env var > config file.""" if cli_key: return cli_key ``` `scripts/fetch_astock_accounts.py:231` ```python api_key = get_api_key(cli_key=args.api_key) ``` `scripts/fetch_subscribed_updates.py:13` ```python python3 fetch_subscribed_updates.py --api-key ak_xxx ``` `scripts/fetch_subscribed_updates.py:48-50` ```python def get_api_key(cli_key=None): if cli_key: return cli_key ``` `scripts/fetch_subscribed_updates.py:207` ```python api_key = get_api_key(cli_key=args.api_key) ``` The configuration instructions in `SKILL.md:43` also direct users to place the API key in `~/.qoder/apis/redfox.json` using ordinary shell redirection, without requiring owner-only file permissions. ### Technical Analysis Both network-facing scripts accept the Redfox API key directly as a command-line argument. Command-line arguments are not an appropriate secret-delivery mechanism because they may be: - Recorded in interactive shell history. - Visible to local process-monitoring utilities while the script is running. - Captured by command auditing, orchestration logs, debugging tools, or terminal session recording. - Retained in automation definitions or agent execution transcripts. The alternative configuration-file workflow stores the credential as plaintext. The documented creation procedure does not explicitly set the file mode to `0600`, verify ownership ...[truncated 2146 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--api-key` option and all command-line examples that place credentials in process arguments. 2. Prefer `REDFOX_API_KEY` from a controlled environment or an operating-system credential store. 3. If interactive entry is required, use a non-echoing prompt such as Python's `getpass.getpass()` and do not log the returned value. 4. Create the configuration directory and file with restrictive permissions: - Directory mode: `0700` - Credential file mode: `0600` 5. Before reading the configuration file, verify that: - It is a regular file rather than a symbolic link. - It is owned by the current user. - Group and other permission bits are not set. 6. Avoid printing, serializing, caching, or including the key in exception messages. 7. Update `SKILL.md`, both README files, and script usage examples to describe only secure credential-delivery methods. 8. Recommend narrowly scoped, revocable, and short-lived API credentials where supported. 9. Advise existing users who used the command-line option to remove affected shell-history and automation-log entries and rotate the exposed key. ]]>
