T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:18- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
bin/run.mjs:18-26, 68-76, 145-158, 174-181, 211-220; supporting usage inSKILL.md:41, 49
Vulnerability Type: Sensitive credential exposure
Risk Level: MediumVulnerable 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
View remediation
Remediation Suggestions
- Read the token directly from
process.env.JUST_ONE_API_TOKENinstead of requiring--token, so it does not appear in process arguments. - Remove or deprecate support for supplying
tokenthrough--params-json; otherwise users can still place the credential in process arguments. - 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}`, }, };- Remove
tokenfrom the query-parameter manifest when header authentication is available. - 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
tokenparameter. - 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.
- Use narrowly scoped, short-lived tokens where supported. Apply rate limits, usage alerts, rotation procedures, and prompt revocation for suspected exposure.
- Update
SKILL.mdto instruct users to provide the credential only through the environment and never through command-line arguments or parameter JSON.
- Read the token directly from
