T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:318- Finding
API Token Exposed Through Process Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:42;bin/run.mjs:22-28, 234-238, 268-276, 318-330
Vulnerability Type: Credential exposure through command-line arguments and URL query parameters
Risk Level: MediumVulnerable Code
SKILL.md:42instructs users to pass the secret through a command-line argument:bash node {baseDir}/bin/run.mjs --operation "<operation-id>" --token "$JUST_ONE_API_TOKEN" --params-json '{"key":"value"}'bin/run.mjs:22-28defines the token as a query parameter:js { "defaultValue": null, "description": "Access token for this API service.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" }bin/run.mjs:234-238accepts the token from the process argument list:js if (flag === "--token") { parsed.token = value; index += 1; continue; }bin/run.mjs:268-276injects the supplied credential 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; }bin/run.mjs:318-330serializes every query parameter, including the token, into 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) { a ...[truncated 3000 chars]- Remediation
View remediation
Remediation Suggestions
-
Read
JUST_ONE_API_TOKENdirectly fromprocess.envrather than requiring a--tokencommand-line argument:js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } -
Remove support for credentials in both
--tokenand--params-jsonso callers cannot inadvertently place secrets in process arguments. -
If the service supports it, transmit the token in an authorization header rather than in the URL:
js const requestInit = { method: operation.method, headers: { accept: "application/json", authorization: `Bearer ${token}`, }, }; -
If JustOneAPI currently requires query authentication, the service should add header-based authentication. Until that is available:
- Avoid logging complete request URLs.
- Redact
tokenfrom proxy, gateway, server, and observability logs. - Never include the constructed URL in errors or diagnostics.
- Use short-lived, narrowly scoped credentials where supported.
-
Update
SKILL.mdto invoke the helper without placing the token on the command line:bash JUST_ONE_API_TOKEN="$JUST_ONE_API_TOKEN" node {baseDir}/bin/run.mjs \ --operation "<operation-id>" \ --params-json '{"key":"value"}' -
Rotate the credential if there is evidence that process arguments or full request URLs have already been retained in logs.
-
