T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:326- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
"}' ``` `bin/run.mjs:326-334` copies that argument into the request parameter collection: ```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 = cliToken; } ``` `bin/run.mjs:376-388` serializes all query parameters, including `token`, into the request URL: ```js function applyQueryParams(operation, params, url) { for (const parameter of operation.parameters.filter((item) => item.location === "query")) { const value = params[parameter.name]; if (value === undefined) { continue; } appendValue(url.searchParams, parameter.name, value); } } function appendValue(searchParams, name, value) { if (Array.isArray(value)) { for (const item of value) { appendValue(searchParams, name, item); } return; } if (value && typeof value === "object") { searchParams.append(name, JSON.stringify(value)); return; } searchParams.append(name, String(value)); } ``` The resulting URL, including the token, is transmitted at `bin/run.mjs:237`: ```js response = await fetch(url, requestInit); ``` ### Technical Analysis The token is exposed through two channels: 1. **Process argument exposure:** Passing a secret through `--token` places it in the process argument vec ...[truncated 3286 chars]- Remediation
View remediation
"}' ``` 6. **Operational safeguards** ...[truncated 212 chars]
