T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:192
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters## Vulnerability Details **File Location**: `bin/run.mjs:17-27, 192-211, 260-270, 298-309, 341-349`; `SKILL.md:53-61` **Vulnerability Type**: Credential exposure through command-line arguments and URL query strings **Risk Level**: Medium ### Vulnerable Code `bin/run.mjs:17-27` defines the access token as a query parameter: ```js { "defaultValue": null, "description": "Access token for this API service.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" }, ``` `bin/run.mjs:192-211` adds all query parameters, including the token, to 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); ``` `bin/run.mjs:260-270` accepts the credential as a process command-line argument: ```js if (flag === "--params-json") { parsed.paramsJson = value; index += 1; continue; } if (flag === "--token") { parsed.token = value; index += 1; continue; } fail(`Unknown argument "${flag}".`); ``` `bin/run.mjs:298-309` transfers the command-line 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; } ``` `bin/run.mjs:341-349` serializes the tok ...[truncated 3462 chars]
- Remediation
- ## Remediation Suggestions 1. **Remove command-line token handling.** Read the credential directly from `process.env.JUST_ONE_API_TOKEN` so it is not included in the process argument vector. ```js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } ``` 2. **Use an authentication header.** If supported by JustOneAPI, transmit the credential using an authorization header rather than a query parameter: ```js const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; ``` 3. **Separate authentication from ordinary parameters.** Remove `token` from the public operation parameter definitions and reject `token` inside `--params-json`. This prevents user-controlled parameter data from overriding the protected credential source. 4. **If query authentication is mandatory**, use short-lived and narrowly scoped tokens. Ensure the client, API gateway, reverse proxy, server, and monitoring systems redact the `token` query parameter from access logs, errors, traces, and telemetry. 5. **Update the documentation.** Replace the `--token "$JUST_ONE_API_TOKEN"` example with environment-only invocation and clearly document any unavoidable query-string exposure. 6. **Rotate potentially exposed credentials.** Tokens previously used through this helper should be rotated if process arguments, command execution, or request URLs may have been logged.
