T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:199- Finding
API Token Exposed Through Command-Line Arguments and URL Query Parameters
- Content
View full analysis
"}' ``` The manifest declares the token as a query parameter: ```js { "defaultValue": null, "description": "User authentication token.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" }, ``` The command-line parser reads the token from `--token`: ```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; } fail(`Unknown argument "${flag}".`); } return parsed; } ``` The token is copied into the request parameters: ```js function injectToken(operation, params, cliToken) { const tokenParam = operation.parameters.find((parameter) => parameter.name === "token"); if (!tokenParam || params.token !== undefined) { return; } if (!c ...[truncated 3341 chars]- Remediation
View remediation
` header or the provider's documented authentication header. - Remove `token` from the operation's query-parameter list so generic query construction cannot append it to the URL. 3. **If the upstream API mandates query authentication:** - Continue reading the secret only from the environment or a protected secret manager. - Construct the authenticated URL immediately before transmission and do not print, persist, or include it in error payloads. - Configure API gateways, reverse proxies, access logs, and observability tooling to redact the `token` parameter. - Avoid exposing complete request URLs in tracing spans and network error reports. - Document the residual URL-logging risk clearly. 4. **Limit credential impact.** - Use short-lived and narrowly scoped tokens where the service supports them. - Apply usage limits and anomaly detection. - Establish token rotation and immediate revocation procedures. 5. **Update all documentation and generated specifications.** - Replace the documented `--token "$JUST_ONE_API_TOKEN"` invocation with environment-only authentication. - Ensure `SKILL.md`, `generated/operations.json`, and `generated/operations.md` accurately reflect the hardened authentication mechanism. ]]>
