T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:136
- Finding
- API Token Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `bin/run.mjs:136-140`; documented usage at `SKILL.md:41` **Vulnerability Type**: Credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```js if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` The documented invocation explicitly expands the secret into the command-line argument vector: ```bash node {baseDir}/bin/run.mjs --operation "searchRecommendV1" --token "$JUST_ONE_API_TOKEN" --params-json '{"keyword":"<keyword>"}' ``` ### Technical Analysis The helper accepts the JustOneAPI access token through the `--token` command-line option. When the documented shell command is executed, the shell expands `JUST_ONE_API_TOKEN`, placing its value directly in the Node.js process argument vector. Depending on operating-system access controls and deployment configuration, command-line arguments may be visible through process inspection utilities, process metadata interfaces, monitoring agents, crash reports, audit systems, or telemetry collectors. The implementation does not print the token itself, but accepting it through `process.argv` unnecessarily increases the number of local systems that may observe the credential. This behavior exceeds minimum privilege in credential handling because the declared API functionality can instead obtain the required token directly from the already-declared `JUST_ONE_API_TOKEN` environment variable or through protected standard input. ### Attack Path 1. A user follows the command documented in `SKILL.md`. 2. The shell expands `$JUST_ONE_API_TOKEN` into the plaintext token. 3. The token becomes part of the Node.js process argument vector. 4. A local user, privileged process-monitoring service, diagnostic collector, or telemetry system captures the command-line arguments. 5. An attacker or unauthorized operator retrieves the token from the captured process metadata. 6. The token is replayed against JustOneAPI un ...[truncated 645 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Read the declared environment variable directly instead of requiring command-line expansion: ```js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required.", { operationId: operation.operationId, }); } ``` 2. Remove the `--token` option from `parseArgs` and update `SKILL.md` to use: ```bash JUST_ONE_API_TOKEN="$JUST_ONE_API_TOKEN" node {baseDir}/bin/run.mjs \ --operation "searchRecommendV1" \ --params-json '{"keyword":"<keyword>"}' ``` 3. Where stronger isolation is required, accept credentials through protected standard input or an operating-system secret manager. 4. Ensure process monitoring, crash reporting, and telemetry systems redact historical `--token` values. 5. Rotate any token that may already have been captured in process logs or monitoring data. ]]>
