T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:18- Finding
API Credential Exposed Through Command-Line Arguments and URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
bin/run.mjs:18-27,bin/run.mjs:73-86,bin/run.mjs:241-251, andSKILL.md:45-50
Vulnerability Type: API credential exposure
Risk Level: MediumVulnerable Code
bin/run.mjs:18-27defines the API token as a query parameter:javascript { "defaultValue": null, "description": "Security token for API access.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" },bin/run.mjs:73-86injects the supplied token into the parameter collection and subsequently constructs the request URL: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", },bin/run.mjs:241-251serializes every query parameter, including the API token, into the URL:javascript 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); } }SKILL.md:45-50instructs users to expose the token as a command-line argument:bash node {baseDir}/bin/run.mjs --operation "getUserPostV1" --token "$JUST_ONE_API_TOKEN" --params-json '{"secUid":"<secUid>"}'markdown - Required: `JUST_ONE_API_TOKEN` - Pass the token with `--token "$JUST_ONE_API_TOKEN"`; do not paste token values into chat messages, screenshots, or logs.Technical Analysis
...[truncated 2860 chars]
- Remediation
View remediation
Remediation Suggestions
-
Use authorization headers where supported. Remove the token from the operation's query-parameter definition and transmit it through an authentication header, for example:
javascript 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}`, }, };Use the exact authentication scheme required by the upstream API.
-
Read the credential directly from the environment. Remove or deprecate
--tokenso the secret is not placed in the process argument vector. If interactive input is required, obtain it through a non-echoing input mechanism rather than a command-line argument. -
Prevent token injection through general parameters. Reject
tokeninside--params-json; otherwise callers could still place the credential into the generated URL after command-line token support is removed. -
Redact secrets defensively. Ensure request URLs, exceptions, debug output, telemetry, and backend error payloads never expose
token,authorization, or equivalent sensitive values. -
If query authentication is mandatory upstream, read the token directly from the environment, document the residual URL-logging risk, disable or redact query-string logging across proxies and monitoring systems, use narrowly scoped short-lived credentials, and rotate any token suspected of having been logged.
-
Update the documentation. Replace the
--token "$JUST_ONE_API_TOKEN"example with an environment-based invocation that does not expose the credential through command-line arguments.
-
