T09 · Insecure Skill Coding Practices
Warning
- Location
- src/index.js:13
- Finding
- API Key Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `src/index.js:13-20` **Related Documentation**: `SKILL.md:26-27`, `README.md:34-41` **Vulnerability Type**: Sensitive credential exposure through process arguments and shell history **Risk Level**: Medium ### Vulnerable Code ```js // Parse CLI args const args = process.argv.slice(2); let apiKey = null; let command = null; let symbol = 'BTC'; for (let i = 0; i < args.length; i++) { if (args[i] === '--key' && args[i + 1]) { apiKey = args[i + 1]; i++; ``` The documented invocation explicitly instructs users to place the secret on the command line: ```bash tradebot-alpha --key YOUR_API_KEY analyze BTC tradebot-alpha --key YOUR_API_KEY status ``` The credential is subsequently sent to the declared API as a Bearer token: ```js const res = await fetch(`${API_BASE}${endpoint}`, { headers: { 'Authorization': `Bearer ${apiKey}` } }); ``` ### Technical Analysis The implementation obtains the API key from `process.argv`. Command-line arguments are not an appropriate secret-input channel because they can be retained in shell history, captured by terminal logging or monitoring software, and exposed through process-inspection facilities while the command is running. Sending the key in an HTTPS Authorization header to the fixed and documented `https://tradebot-alpha.bluefeza.com/api/v1` endpoint is consistent with the Skill's declared authenticated API-fetching function. No transmission to an undeclared host was identified. The vulnerability is the unnecessary local exposure created by the credential-input mechanism, not the authenticated network request itself. ### Attack Path 1. A user follows the supplied instructions and runs the CLI with `--key REAL_API_KEY`. 2. The shell may persist the complete command, including the API key, in its history. 3. While the process is running, a local process or monitoring facility with sufficient access may inspect its command-line arguments. 4. An attacker who ...[truncated 1079 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove or deprecate the `--key` argument so credentials are not placed in process arguments. 2. Prefer an operating-system credential store or a configuration file readable only by the owning user. 3. If environment-variable support is provided, document its residual exposure risks and use a narrowly named variable such as `TRADEBOT_ALPHA_API_KEY`. 4. Provide an interactive hidden prompt for ad hoc use, ensuring that input echo is disabled. 5. Never print, log, include in error messages, or persist the full API key. 6. Update `SKILL.md`, `README.md`, and CLI help output to use the protected credential mechanism. 7. Allow users to revoke and rotate exposed keys, and recommend that existing users remove commands containing keys from shell-history files. 8. On the service side, use scoped, revocable, expiring credentials and apply rate limits to reduce the impact of credential theft. ]]>
