T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:196
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `bin/run.mjs:22-27, 91-109, 164-167, 196-206, 239-260`; documented usage at `SKILL.md:43-51` **Vulnerability Type**: Credential exposure through command-line arguments and URL query parameters **Risk Level**: Medium ### Vulnerable Code `SKILL.md:43-51`: ```markdown node {baseDir}/bin/run.mjs --operation "titleBoxOfficeSummary" --token "$JUST_ONE_API_TOKEN" --params-json '{"id":"<id>"}' ``` ```markdown - Required: `JUST_ONE_API_TOKEN` - Pass the token with `--token "$JUST_ONE_API_TOKEN"`; do not paste token values into chat messages, screenshots, or logs. ``` `bin/run.mjs:22-27` defines the credential as a query parameter: ```js { "defaultValue": null, "description": "User's authentication token.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" }, ``` `bin/run.mjs:91-109` constructs the URL and sends it: ```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) { ``` `bin/run.mjs:164-167` accepts the secret through a command-line argument: ```js if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` `bin/run.mjs:196-206` injects that secret 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) ...[truncated 3784 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Stop passing credentials through command-line arguments.** - Read the token directly from `process.env.JUST_ONE_API_TOKEN`. - If an explicit alternative is necessary, accept a protected file descriptor or restricted-permission credential file rather than a plaintext CLI value. - Remove `--token` from the documented command and argument parser. 2. **Use an authentication header instead of a query parameter.** - Prefer the service’s supported `Authorization` header, such as: ```js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; ``` - Remove `token` from the operation’s query-parameter definitions so that generic query construction cannot append it to the URL. 3. **Coordinate an API contract change if query authentication is currently mandatory.** - Add header-based authentication on the JustOneAPI backend. - Until that change is available, explicitly document the residual exposure and configure gateways, servers, proxies, and observability systems to redact the `token` query parameter. 4. **Implement defense-in-depth redaction.** - Never include complete request URLs, authentication headers, or token values in error messages. - Redact keys named `token`, `authorization`, `apiKey`, or similar before emitting diagnostics. - Ensure tracing and HTTP instrumentation do not capture sensitive query values. 5. **Rotate potentially exposed credentials.** - Revoke and replace tokens that may already have appeared in process telemetry or URL logs. - Apply the narrowest available API scope, rate limits, expiration period, and usage alerts to reduce the impact of future disclosure. ]]>
