T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:18
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters## Vulnerability Details **File Location**: `bin/run.mjs:18-26, 68-76, 145-158, 174-181, 211-220`; supporting usage in `SKILL.md:41, 49` **Vulnerability Type**: Sensitive credential exposure **Risk Level**: Medium ### Vulnerable Code ```js { "description": "Access token for this API service.", "location": "query", "name": "token", "required": true, "schemaType": "string" } ``` ```js const params = parseParams(args.paramsJson); applyDefaults(operation, params); injectToken(operation, params, args.token); validateRequired(operation, params); const baseUrl = manifest.baseUrl; const url = new URL(operation.path, ensureBaseUrl(baseUrl)); applyPathParams(operation, params, url); applyQueryParams(operation, params, url); ``` ```js if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` ```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; } ``` ```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); } } ``` The documented invocation also places the credential in a command-line argument: ```bash node {baseDir}/bin/run.mjs --operation "searchKuaishouUserV2" --token "$JUST_ONE_API_TOKEN" --params-json '{"keyword":"<keyword>"}' ``` ### Technical Analysis The helper accepts the API credential through `--token`, making the secret part of the Node process command line. Depending on operating-system policy and execution environment, process arguments may be observable ...[truncated 2304 chars]
- Remediation
- ## Remediation Suggestions 1. Read the token directly from `process.env.JUST_ONE_API_TOKEN` instead of requiring `--token`, so it does not appear in process arguments. 2. Remove or deprecate support for supplying `token` through `--params-json`; otherwise users can still place the credential in process arguments. 3. Prefer an authorization header when supported by the upstream service: ```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}`, }, }; ``` 4. Remove `token` from the query-parameter manifest when header authentication is available. 5. If JustOneAPI only accepts query-string authentication, document this residual risk and configure clients, proxies, gateways, application logs, tracing systems, and error-reporting tools to redact the `token` parameter. 6. Ensure errors never include complete request URLs and add automated tests verifying that credentials do not appear in standard output, standard error, or diagnostic messages. 7. Use narrowly scoped, short-lived tokens where supported. Apply rate limits, usage alerts, rotation procedures, and prompt revocation for suspected exposure. 8. Update `SKILL.md` to instruct users to provide the credential only through the environment and never through command-line arguments or parameter JSON.
