T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/deploy.js:18
- Finding
- API Keys Can Be Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/deploy.js:18-33`; equivalent behavior appears in `scripts/download.js:17-28`, `scripts/files.js:11-22`, `scripts/list.js:11-21`, and `scripts/delete.js:12-22`. The `-k` option is documented in `SKILL.md:115-139` and `SKILL.md:167`. **Vulnerability Type**: Credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```js function parseArgs() { const args = process.argv.slice(2); const options = { sourceDir: '.', apiKey: process.env.STATIC_APP_API_KEY, pid: null, exclude: null, keepZip: false }; for (let i = 0; i < args.length; i++) { const arg = args[i]; if (arg === '-k' || arg === '--api-key') { options.apiKey = args[++i]; ``` The same command-line credential pattern is implemented by every API utility. The documentation explicitly presents it as a supported option: ```markdown Options: - `--raw` — Output raw JSON - `-k <key>` — Specify API key ``` ### Technical Analysis Static.app API keys are bearer credentials capable of authenticating account operations. Accepting the key through `-k` or `--api-key` places it in `process.argv`. Depending on the host configuration, command-line arguments may be observable through: - Process inspection utilities and `/proc` metadata. - Shell history. - Agent tool-call and execution logs. - Terminal session recording. - Endpoint monitoring and process auditing products. - Wrapper scripts that record invoked commands. The scripts also support `STATIC_APP_API_KEY`, which is safer than a command-line parameter in many environments, but the insecure alternative remains enabled and documented. The behavior is unnecessary for the declared functionality because authentication can be supplied through a secret manager, protected environment injection, standard input, or a restricted credential file. ### Attack Path 1. A user or AI agent invokes a utility with a credential, for example: ``` ...[truncated 1119 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `-k` and `--api-key` command-line options from all scripts. 2. Obtain the credential from a secret manager or a protected environment variable injected only into the child process. 3. If interactive entry is required, read the key from a hidden prompt or standard input without echoing it. 4. Optionally support a credential file, but require restrictive permissions and reject files readable by other users. 5. Update `SKILL.md` so examples never place keys directly in commands. 6. Add a warning and migration period if backward compatibility requires temporary support for `--api-key`. 7. Ensure agent execution logs, errors, and telemetry redact strings matching the Static.app key format. 8. Use narrowly scoped and short-lived API credentials where supported, and rotate any keys previously supplied through command-line arguments. ]]>
