T09 · Insecure Skill Coding Practices
- Location
- scripts/aicoin.mjs:129
- Finding
- API credentials exposed through command-line arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:80-85`; `scripts/aicoin.mjs:129-149` **Vulnerability Type**: Credential exposure through process arguments and shell history **Risk Level**: Medium ### Vulnerable Code ```bash node scripts/aicoin.mjs set-key <key_id> <secret> node scripts/aicoin.mjs set-key '{"api_key":"<id>","access_key":"<secret>"}' ``` ```js const raw = rest.join(' ').trim(); if (raw.startsWith('{')) { try { const j = JSON.parse(raw); id = j.access_key_id || j.accessKeyId || j.key_id || j.api_key || j.key; secret = j.access_secret || j.accessSecret || j.secret_key || j.secret || j.access_key; } catch { return out({ ok: false, error: { code: 'bad_json', message: 'Invalid JSON argument' } }); } } else if (rest.length >= 2) { id = rest[0]; secret = rest[1]; } const r = await saveKey(id, secret); ``` ### Technical Analysis The documented `set-key` workflow requires users to place the AiCoin secret directly in a command-line argument. The implementation then reads that secret from `process.argv`. Command-line secrets can be exposed through: - Interactive shell history files. - Process inspection utilities while the command is running. - Process accounting and endpoint monitoring systems. - Terminal session recording. - Diagnostic logs that capture invoked commands. - Automation logs that echo command lines. The JSON input alternative has the same weakness because the entire JSON object, including the secret, remains part of the process argument list. This behavior is not required for the Skill's market-data functionality. Credentials can instead be supplied through masked interactive input, standard input, or a credential-management facility. ### Attack Path 1. A user follows the documented `set-key` example and enters the API key ID and secret in a terminal. 2. The shell records the command in its history, or the operating system exposes the arguments through process inspection. 3. A local use ...[truncated 845 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove secret-bearing command-line examples from `SKILL.md`. 2. Accept the secret through a masked interactive prompt using a terminal input mechanism that disables echo. 3. For non-interactive use, accept the secret through standard input or a file descriptor rather than `process.argv`. 4. Prefer integration with an operating-system credential store or the host agent's secret-management interface. 5. Ensure errors and debug logs never include the supplied secret or raw input object. 6. Clearly warn users to rotate any credential previously entered on the command line and to remove affected shell-history entries. 7. If command-line compatibility must temporarily remain, display a security warning and deprecate the interface. ]]>
