T09 · Insecure Skill Coding Practices
Warning
- Location
- waifugenerator.js:11
- Finding
- API Token Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `waifugenerator.js:11-12, 22-29`; documented in `SKILL.md:13-17` and `README.md:71-76` **Vulnerability Type**: Sensitive credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```javascript } else if (args[i] === "--token" && args[i + 1]) { tokenFlag = args[++i]; } ``` ```javascript // --- Token resolution --- const TOKEN = tokenFlag; if (!TOKEN) { console.error("Token required. Pass via: --token YOUR_TOKEN"); process.exit(1); } ``` The documented invocation explicitly places the credential on the command line: ```bash node <script> "your prompt" --token YOUR_TOKEN ``` ### Technical Analysis The skill accepts its Neta API token exclusively through the `--token` command-line argument. Command-line arguments are not an appropriate secret-transport mechanism because they can be exposed through: - Shell history files. - Process listings and process inspection interfaces. - Command telemetry, terminal logging, or audit systems. - Wrapper scripts and automation logs that record complete commands. The token is legitimately transmitted to the intended API through the `x-token` header, but its initial acquisition through `process.argv` unnecessarily exposes it on the local system. No hardcoded token or transmission to an unrelated domain was identified. ### Attack Path 1. A user follows the documented command and supplies a valid token using `--token`. 2. The shell records the complete command in its history, or the argument remains visible through process inspection while the script is running. 3. Another local user, monitoring tool, support bundle, or log collector obtains the command-line contents. 4. The exposed token is extracted and replayed against the Neta API. 5. The attacker performs API operations within the authorization and quota associated with the compromised token. ### Impact Assessment Successful exploitation does not grant additional operating-syst ...[truncated 324 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Support a protected environment variable, such as `NETA_API_TOKEN`, as the primary authentication source. 2. Support reading the token interactively from a hidden terminal prompt or from standard input without echoing it. 3. If `--token` must remain for compatibility, mark it as insecure and deprecated. 4. Update all documentation examples so they do not embed credentials in command lines. 5. Avoid including tokens in exceptions, debug output, telemetry, or request diagnostics. 6. Recommend short-lived, narrowly scoped tokens and provide token-rotation instructions. Example hardening approach: ```javascript const TOKEN = process.env.NETA_API_TOKEN; if (!TOKEN) { console.error("Token required. Set NETA_API_TOKEN or provide it through a secure prompt."); process.exit(1); } ``` Document usage without placing the secret directly in the command: ```bash read -s NETA_API_TOKEN export NETA_API_TOKEN node waifugenerator.js "your prompt" unset NETA_API_TOKEN ``` ]]>
