T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:220- Finding
API Access Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:47,SKILL.md:55;bin/run.mjs:111-117,bin/run.mjs:220-230,bin/run.mjs:258-267
Vulnerability Type: Sensitive credential exposure
Risk Level: MediumThe documented invocation passes the API token as a command-line argument:
bash node {baseDir}/bin/run.mjs --operation "searchWeixinV1" --token "$JUST_ONE_API_TOKEN" --params-json '{"keyword":"<keyword>"}'The helper subsequently injects that 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; }Because the manifest defines
tokenas a query parameter,applyQueryParamsplaces the credential in 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) { appendValue(searchParams, name, item); } return; } if (value && typeof value === "object") { searchParams.append(name, JSON.stringify(value)); return; } searchParams.append(name, String(value)); }The resulting URL is then sent to the fixed JustOneAPI HTTPS endpoint:
js let response; try { response = await fetch(url, requestInit); } catch (error) { fail("Network request failed.", { cause: error ...[truncated 2343 chars]- Remediation
View remediation
Remediation Suggestions
- Read the token directly from
process.env.JUST_ONE_API_TOKENinside the Node.js process instead of requiring a--tokenargument. - Remove or deprecate the CLI token option so credentials do not appear in process listings or process telemetry.
- If JustOneAPI supports header-based authentication, send the token through an
Authorizationheader rather than a query parameter: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}`, }, }; - If the upstream API mandates query-string authentication, ensure the helper never prints the complete request URL. Configure gateways, proxies, servers, tracing systems, and error-reporting tools to redact the
tokenparameter. - Restrict access to network and process telemetry, minimize log retention, and prevent shell tracing around credential-bearing commands.
- Update
SKILL.mdto document environment-only credential loading rather than command-line token passing. - Rotate any token that may previously have appeared in process monitoring or URL logs, and use narrowly scoped, short-lived credentials where supported.
- Read the token directly from
