T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:231- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
bin/run.mjs:20-25, 76-98, 139-155, 185-195, 231-237;SKILL.md:42, 49-50
Vulnerability Type: Sensitive credential exposure
Risk Level: MediumVulnerable Code
bin/run.mjs:20-25js { "defaultValue": null, "description": "Authentication token required for API access.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" }bin/run.mjs:76-98js 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);bin/run.mjs:139-155js 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; continue; } if (flag === "--params-json") { parsed.paramsJson = value; index += 1; continue; } if (flag === "--token") { parsed.token = value; index += 1; continue; }bin/run.mjs:185-195js function injectToken(operation, params, cliToken) { const tokenParam = operation.parameters.find((parameter) => parameter.name === "token"); ...[truncated 3045 chars]- Remediation
View remediation
Remediation Suggestions
- Read the token directly from
process.env.JUST_ONE_API_TOKENinside the Node process instead of requiring--token. This prevents ordinary command-line process listings from exposing the value. - If supported by JustOneAPI, transmit the credential in an
Authorizationheader rather than in the URL: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 generic query-parameter manifest and prevent user-suppliedparams.tokenvalues from overriding the trusted credential source. - If the backend requires query authentication and cannot be changed, request a server-side authentication redesign. Until then, ensure clients, reverse proxies, API gateways, observability systems, and server logs redact the
tokenquery parameter. - Update
SKILL.mdso the invocation does not place the token on the command line:bash JUST_ONE_API_TOKEN="$JUST_ONE_API_TOKEN" node {baseDir}/bin/run.mjs --operation "getTwitterUserPostsV1" --params-json '{"restId":"user-rest-id"}' - Avoid including complete request URLs in errors, traces, analytics, or debug output, and rotate any token suspected of having been logged or exposed.
- Read the token directly from
