T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:126- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
bin/run.mjs:126-155, 194-227, 264-276; additionally documented inSKILL.md:48, 54
Vulnerability Type: API credential exposure through command-line arguments and URL query strings
Risk Level: MediumVulnerable Code
SKILL.md:48instructs users to pass the secret as a process argument:bash node {baseDir}/bin/run.mjs --operation "getProductsByCategoryV1" --token "$JUST_ONE_API_TOKEN" --params-json '{"categoryId":"<categoryId>"}'bin/run.mjs:126-155constructs and sends the request:javascript 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); const requestInit = { headers: { "accept": "application/json", }, method: operation.method, }; if (operation.requestBody && params.body !== undefined) { requestInit.body = JSON.stringify(params.body); requestInit.headers["content-type"] = operation.requestBody.contentType || "application/json"; } let response; try { response = await fetch(url, requestInit); } catch (error) { fail("Network request failed.", { cause: error instanceof Error ? error.message : String(error), operationId: operation.operationId, }); }bin/run.mjs:194-227reads the token from the command line and places it into the parameter object:javascript function parseArgs(argv) { const parsed = { operation: null, paramsJson: "{}", token: null }; for (let index = 0; index < argv.length; index += 1) { const flag = argv[index]; const value = argv[index + 1]; if (flag === "--operation") { parsed.operation = value; index += 1; ...[truncated 4190 chars]- Remediation
View remediation
Remediation Suggestions
-
Read the credential directly from
process.env.JUST_ONE_API_TOKENinstead of accepting it through--token:javascript const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } -
If supported by JustOneAPI, transmit the credential in an authentication header rather than the URL:
javascript const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; -
Remove
tokenfrom the operation's ordinary query-parameter collection so generic parameter processing cannot accidentally serialize it into URLs. -
If the upstream API exclusively requires query-string authentication, isolate token insertion from ordinary parameters and treat the resulting URL as sensitive. Never print, persist, or include the complete URL in errors or telemetry.
-
Configure clients, proxies, gateways, monitoring systems, and API access logs to redact
tokenand equivalent authentication fields. -
Reject credentials supplied inside
--params-jsonto ensure callers cannot bypass the safer credential path. -
Update
SKILL.mdto instruct users to setJUST_ONE_API_TOKENin the environment without passing its value as a command-line argument. -
Rotate any token that may already have been exposed through process monitoring, command auditing, CI logs, or URL access logs.
-
