T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:27- Finding
API Token Exposed Through Command-Line Arguments and URL Query Parameters
- Content
View full analysis
"}' ``` From `bin/run.mjs:27-35`: ```js { "defaultValue": null, "description": "Access token for the API.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" } ``` From `bin/run.mjs:70-93`: ```js const baseUrl = manifest.baseUrl; const url = new URL(operation.path, ensureBaseUrl(baseUrl)); applyPathParams(operation, params, url); applyQueryParams(operation, params, url); const requestInit = { headers: { "accept": "application/json", }, method: operation.method, }; if (operation.requestBody && params.body !== undefined) { requestInit.body = JSON.stringify(params.body); requestInit.headers["content-type"] = operation.requestBody.contentType || "application/json"; } let response; try { response = await fetch(url, requestInit); } catch (error) { fail("Network request failed.", { cause: error instanceof Error ? error.message : String(error), operationId: operation.operationId, }); } ``` From `bin/run.mjs:173-185`: ```js 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 = c ...[truncated 3323 chars]- Remediation
View remediation
"}' ``` 5. **If the upstream API mandates query-string authentication**, explicitly document that limitation and apply compensating controls: - Use narrowly scoped and short-lived tokens. - Redact `token` from proxy, gateway, application, and monitoring logs. - Never print or include the complete request URL in errors. - Disable shell history for credential-bearing commands. - Rotate any token suspected of appearing in logs or process telemetry. - Restrict access to operational logs and apply short retention periods. 6. **Add automated safeguards.** Include tests that verify secrets do not appear in command-line examples, emitted errors, standard output, diagnostic events, or URLs when header authentication is available. ]]>
