T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:23- Finding
API Token Exposed Through Command-Line Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
bin/run.mjs:23-30, 84-86, 101, 151-155, 236-243;SKILL.md:43;generated/operations.json:16-23;generated/operations.md:19
Vulnerability Type: Credential exposure through process arguments and URL query strings
Risk Level: MediumVulnerable Code
bin/run.mjs:23-30defines the authentication token as a query parameter:js { "defaultValue": null, "description": "User authentication token.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" },bin/run.mjs:84-86injects the command-line token into the request parameters:js const params = parseParams(args.paramsJson); applyDefaults(operation, params); injectToken(operation, params, args.token);bin/run.mjs:101sends the resulting URL:js response = await fetch(url, requestInit);bin/run.mjs:151-155reads the token from a command-line argument:js if (flag === "--token") { parsed.token = value; index += 1; continue; }bin/run.mjs:236-243appends parameter values, including the token, to the URL query string:js 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)); }SKILL.md:43instructs users to place the token in the process command line:bash node {baseDir}/bin/run.mjs --operation "getDouyinXingtuKolInfoV1" --token "$JUST_ONE_API_TOKEN" --params-json '{"kolId":"<kolId>"}'Technical Analysis
The authentication token is exposed through two c ...[truncated 2363 chars]
- Remediation
View remediation
Remediation Suggestions
-
Read the token directly from
process.env.JUST_ONE_API_TOKENrather than requiring--token, preventing routine exposure through process arguments. -
If supported by JustOneAPI, send authentication in an HTTP header:
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}`, }, redirect: "error", }; -
Remove the token from
operation.parametersso that generic query-parameter processing cannot append it to the URL. -
Reject a
tokenproperty supplied through--params-json, ensuring that credentials follow only the controlled authentication path. -
If the upstream API strictly requires query-based authentication, document that residual risk and configure clients, proxies, gateways, tracing systems, and backend services to redact the
tokenquery parameter. -
Disable automatic redirects for authenticated requests or explicitly validate that every redirect remains HTTPS and on the approved origin.
-
Rotate any token suspected of having appeared in process telemetry or URL-bearing logs, and apply the narrowest available token permissions, quotas, and expiration period.
-
