T09 · Insecure Skill Coding Practices
- Location
SKILL.md:42- Finding
API Token Exposed Through Command-Line Arguments
- Content
View full analysis
" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` ```javascript function injectToken(operation, params, cliToken) { const tokenParam = operation.parameters.find((parameter) => parameter.name === "token"); if (!tokenParam || params.token !== undefined) { return; } if (!cliToken) { fail("--token is required for this operation.", { operationId: operation.operationId, }); } params.token = cliToken; } ``` ### Technical Analysis The documented invocation expands `JUST_ONE_API_TOKEN` into the `--token` command-line argument. Although shell expansion does not normally place the expanded value in shell history when the literal command uses an environment variable, the resulting Node.js process receives the actual credential in its argument vector. Depending on the operating system, container configuration, process permissions, and diagnostic tooling, command-line arguments can be visible through process inspection interfaces, monitoring agents, crash diagnostics, audit logs, or process-list utilities. This creates an avoidable credential-disclosure channel. The executable also permits `token` to be supplied inside `--params-json`. Because `injectToken` returns when `params.token` is already defined, callers can bypass the intended `--token` path and place credentials in another command-line argument. Both supported input methods therefore expose the credential through the process argument vector. ### Attack Path 1. A user follows the documented command and invokes the helper with `--token "$JUST_ONE_API_TOKEN"`. 2. The shell expands the environment variable before starting Node.js. 3. The complete token becomes part of the helper process's ar ...[truncated 947 chars]- Remediation
View remediation
" --params-json '{"key":"value"}' ``` 3. Reject `token` when it appears in `--params-json` so callers cannot reintroduce command-line disclosure: ```javascript if (Object.prototype.hasOwnProperty.call(params, "token")) { fail("Do not provide token through --params-json."); } ``` 4. Avoid printing credentials or complete authenticated request URLs in errors, debug output, telemetry, or crash reports. 5. Rotate any token that may already have been exposed through process monitoring or diagnostic collection. ]]>
