T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:318
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters## Vulnerability Details **File Location**: `SKILL.md:42`; `bin/run.mjs:22-28, 234-238, 268-276, 318-330` **Vulnerability Type**: Credential exposure through command-line arguments and URL query parameters **Risk Level**: Medium ### Vulnerable Code `SKILL.md:42` instructs users to pass the secret through a command-line argument: ```bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}' ``` `bin/run.mjs:22-28` defines the 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:234-238` accepts the token from the process argument list: ```js if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` `bin/run.mjs:268-276` injects the supplied credential 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:318-330` serializes every query parameter, including the token, into the 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); } } function appendValue(searchParams, name, value) { if (Array.isArray(value)) { for (const item of value) { a ...[truncated 3000 chars]
- Remediation
- ## Remediation Suggestions 1. Read `JUST_ONE_API_TOKEN` directly from `process.env` rather than requiring a `--token` command-line argument: ```js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } ``` 2. Remove support for credentials in both `--token` and `--params-json` so callers cannot inadvertently place secrets in process arguments. 3. If the service supports it, transmit the token in an authorization header rather than in the URL: ```js const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; ``` 4. If JustOneAPI currently requires query authentication, the service should add header-based authentication. Until that is available: - Avoid logging complete request URLs. - Redact `token` from proxy, gateway, server, and observability logs. - Never include the constructed URL in errors or diagnostics. - Use short-lived, narrowly scoped credentials where supported. 5. Update `SKILL.md` to invoke the helper without placing the token on the command line: ```bash JUST_ONE_API_TOKEN="$JUST_ONE_API_TOKEN" node {baseDir}/bin/run.mjs \ --operation "<operation-id>" \ --params-json '{"key":"value"}' ``` 6. Rotate the credential if there is evidence that process arguments or full request URLs have already been retained in logs.
