T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:26- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
"}' ``` `SKILL.md:46` reinforces this usage: ```markdown - Pass the token with `--token "$JUST_ONE_API_TOKEN"`; do not paste token values into chat messages, screenshots, or logs. ``` `bin/run.mjs:26-34` declares the authentication token as a required query parameter: ```js { "defaultValue": null, "description": "User authentication token.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" } ``` `bin/run.mjs:88-91` adds all query parameters, including the token, to the URL and sends that URL over the network: ```js applyPathParams(operation, params, url); applyQueryParams(operation, params, url); const requestInit = { headers: { "accept": "application/json", }, method: operation.method, }; ``` The resulting URL is subsequently supplied to `fetch`: ```js 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, }); } ``` `bin/run.mjs:149-153` reads the token directly from the command-line argument vector: ```js if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` `bin/run.mjs:203-212` serializes every query parameter into the request URL: ```js function applyQueryParams(operation, params, url) { for (const parameter of operation.parameters.filter((item) => item.location === "query")) { const value = params[par ...[truncated 2898 chars]- Remediation
View remediation
"}' ``` 2. **Prefer an authorization header.** If supported by JustOneAPI, keep the token out of the URL: ```js const requestInit = { headers: { accept: "application/json", authorization: `Bearer ${token}`, }, method: operation.method, }; ``` 3. **If the upstream API mandates query authentication**, document the residual risk and implement compensating controls: - Never print or serialize the complete request URL. - Redact `token` from exceptions, diagnostics, telemetry, and debug output. - Configure reverse proxies and API gateways not to log sensitive query parameters. - Use short-lived, narrowly scoped tokens where the provider supports them. - Rotate the token immediately after suspected disclosure. - Restrict access to process telemetry and network logs. 4. **Reject tokens supplied through `--params-json`.** The current injection logic accepts `params.token` in preference to `--token`. Remove token handling from general request parameters so credentials cannot accidentally be persisted in command history or application logs. 5. **Add regression tests** confirming that the token does not appear in process arguments, standard output, standard error, diagnostic messages, or request URLs when header-based authentication is available. ]]>
