T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:325- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` The helper copies that command-line value 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; } ``` All query parameters, including `token`, are then appended to the URL: ```javascript 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 is sent to the external API: ```javascript 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", }, me ...[truncated 2646 chars]- Remediation
View remediation
" \ --params-json '{"key":"value"}' ``` Prefer secret injection by the execution environment over inline shell assignment where available. 5. If the upstream service strictly requires query-string authentication: - Clearly disclose the residual URL-logging risk. - Ensure clients, gateways, proxies, tracing systems, and server logs redact the `token` parameter. - Never include the complete request URL in errors or diagnostics. - Use short-lived, narrowly scoped, and readily revocable tokens. - Rotate the token after suspected process-list or log exposure. 6. Prevent callers from overriding authentication through `params.token`; authentication should come exclusively from the trusted environment-variable path. ]]>
