T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:734
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `bin/run.mjs:734-756`, `bin/run.mjs:797-813`, `bin/run.mjs:844-853`, `bin/run.mjs:881-889`; usage documented at `SKILL.md:41` **Vulnerability Type**: Credential exposure through command-line arguments and URL query strings **Risk Level**: Medium ### Vulnerable Code The documented invocation passes the API token as a command-line argument: ```bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` The helper parses the token from the process argument list: ```javascript 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; } fail(`Unknown argument "${flag}".`); } return parsed; } ``` It then injects the token into the request parameters: ```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; } ``` Every operation defines `token` as a query parameter. The request construction consequently places the credential in the URL: ```javascript const params = parseParams(args.paramsJson); applyDefaults(operation, params); injectToken(operation, params, args.token); validateRequired(operation, params); const baseUrl = manifest.baseUrl; const url = ne ...[truncated 3557 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Stop passing credentials through command-line arguments** - Read `JUST_ONE_API_TOKEN` directly from `process.env`. - Remove or deprecate the `--token` argument. - Emit an error when the environment variable is unavailable without printing its value. ```javascript const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } ``` 2. **Use an authentication header** - If supported by JustOneAPI, send the token through an `Authorization` header rather than the query string: ```javascript const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; ``` - Remove `token` from each operation's query-parameter definitions and update both generated operation files. 3. **Prevent alternate query-string injection** - Reject a `token` property supplied through `--params-json`. - Keep credentials separate from user-controlled operation parameters. ```javascript if (Object.prototype.hasOwnProperty.call(params, "token")) { fail("The token must not be supplied through --params-json."); } ``` 4. **If the upstream API requires query authentication** - Continue using HTTPS, but document that the upstream design requires URL-based credentials. - Configure API gateways, reverse proxies, access logs, and observability systems to redact the `token` query parameter. - Ensure errors and diagnostics never serialize the complete request URL. - Use short-lived, narrowly scoped, revocable tokens and rotate any token suspected of exposure. 5. **Update documentation** - Replace the `--token "$JUST_ONE_API_TOKEN"` example in `SKILL.md` with environment-only credential loading. - Clearly document token scope, rotation, revocation, and log-redaction requirements. ]]>
