T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:219
- Finding
- API Credential Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:40`; `bin/run.mjs:219-235` **Vulnerability Type**: API credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code `SKILL.md:40`: ```bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` `bin/run.mjs:219-235`: ```js function parseArgs(argv) { const parsed = { operation: null, paramsJson: "{}", token: null }; for (let index = 0; index < argv.length; index += 1) { const flag = argv[index]; const value = argv[index + 1]; if (flag === "--operation") { parsed.operation = value; index += 1; continue; } if (flag === "--params-json") { parsed.paramsJson = value; index += 1; continue; } if (flag === "--token") { parsed.token = value; index += 1; continue; ``` ### Technical Analysis The documented invocation passes `JUST_ONE_API_TOKEN` as the value of the `--token` command-line argument. The helper then reads the credential directly from `process.argv`. Command-line arguments can be exposed through operating-system process inspection, process-monitoring software, execution telemetry, shell debugging, wrapper scripts, and improperly configured job systems. Expanding the environment variable in the shell does not protect it after expansion: the resulting secret becomes part of the Node.js process argument vector. Authentication is necessary for the Skill's declared TikTok Shop API functionality, but placing the credential in the argument vector creates avoidable exposure and is not a least-exposure credential-handling design. ### 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 into the actual credential. 3. The credential becomes part of the Node.js process argument vector. 4. A local user, process-monito ...[truncated 846 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--token` command-line option and read the credential directly from the declared environment variable: ```js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } ``` 2. Update `SKILL.md` so the command does not expand the secret into an argument: ```bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --params-json '{"key":"value"}' ``` 3. Reject a `token` property supplied through `--params-json`, preventing callers from reintroducing credentials through another serialized command-line argument. 4. Ensure diagnostic output, shell tracing, and execution telemetry never record secret-bearing environment variables. 5. Rotate tokens that may already have appeared in process monitoring, shell traces, or execution logs. ]]>
