T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:249- 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 executable injects that token 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 (!cliToken) { fail("--token is required for this operation.", { operationId: operation.operationId, }); } params.token = cliToken; } ``` All parameters declared as query parameters, including `token`, are then appended to 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); } } ``` The resulting request is sent using the URL containing the credential: ```js 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, }; response = await fetch(url, requestInit); ``` ### Technical Analysis The API token is exposed at two separate layers: 1. The shell expands `$JUST_ONE_API_TOKEN` into the Node.js process argument list. Depending on operating-system permissions and process isolation, other local users, process-monitoring agents, diagnosti ...[truncated 2221 chars]- Remediation
View remediation
" \ --params-json '{"key":"value"}' ``` - Prefer setting the environment variable through a protected secret manager rather than inline shell assignment where shell history or job configuration could retain it. 5. **Apply defense-in-depth controls** - Redact credential-like fields from errors, traces, and logs. - Use short-lived, revocable, and narrowly scoped tokens. - Rotate the existing token if it may already have appeared in process telemetry or URL logs. - Configure API gateways and observability systems to suppress or redact sensitive query parameters if query-based authentication cannot be immediately removed. ]]>
