T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:192- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
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: MediumVulnerable Code
bin/run.mjs:17-27defines 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-211adds 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-270accepts 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-309transfers 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-349serializes the tok ...[truncated 3462 chars]- Remediation
View remediation
Remediation Suggestions
- Remove command-line token handling. Read the credential directly from
process.env.JUST_ONE_API_TOKENso 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."); }- 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}`, }, };-
Separate authentication from ordinary parameters. Remove
tokenfrom the public operation parameter definitions and rejecttokeninside--params-json. This prevents user-controlled parameter data from overriding the protected credential source. -
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
tokenquery parameter from access logs, errors, traces, and telemetry. -
Update the documentation. Replace the
--token "$JUST_ONE_API_TOKEN"example with environment-only invocation and clearly document any unavoidable query-string exposure. -
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.
- Remove command-line token handling. Read the credential directly from
