T09 · Insecure Skill Coding Practices
Warning
- Location
- bin/run.mjs:21
- Finding
- API Token Exposed Through Process Arguments and URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `bin/run.mjs:21-29, 63-75, 142-145, 218-225`; `SKILL.md:37, 45`; `generated/operations.json:16-24`; `generated/operations.md:20` **Vulnerability Type**: Credential exposure through command-line arguments and URL query strings **Risk Level**: Medium ### Vulnerable Code `SKILL.md:37`: ```bash node {baseDir}/bin/run.mjs --operation "markdownV1" --token "$JUST_ONE_API_TOKEN" --params-json '{"url":"<url>"}' ``` `bin/run.mjs:21-29`: ```js { "defaultValue": null, "description": "Authentication token for this API service.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" } ``` `bin/run.mjs:63-75`: ```js 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, }; ``` `bin/run.mjs:142-145`: ```js if (flag === "--token") { parsed.token = value; index += 1; continue; } ``` `bin/run.mjs:218-225`: ```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); } } ``` ### Technical Analysis The documented invocation passes `JUST_ONE_API_TOKEN` through the `--token` command-line argument. Command-line arguments may be visible to other local processes or administrators through process-inspection facilities and may also be retained in shell tracing, job metadata, diagnostic output, or execution telemetry. The manifest declares ...[truncated 2498 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Read the credential directly from `process.env.JUST_ONE_API_TOKEN` rather than requiring it through `--token`: ```js const token = process.env.JUST_ONE_API_TOKEN; if (!token) { fail("JUST_ONE_API_TOKEN is required."); } ``` 2. Remove or deprecate the `--token` option so secrets do not appear in process arguments. If backward compatibility is temporarily required, emit a deprecation warning and prioritize the environment variable. 3. Change the API authentication contract to use a secret-bearing request header, preferably: ```js requestInit.headers.authorization = `Bearer ${token}`; ``` If JustOneAPI uses another authentication scheme, use a dedicated header such as `X-API-Key`. 4. Remove `token` from the operation's query-parameter definitions in `bin/run.mjs`, `generated/operations.json`, and `generated/operations.md`. 5. Reject a `token` property supplied through `--params-json` to prevent callers from reintroducing query-string authentication. 6. If the remote API currently requires query-string authentication, coordinate a server-side migration to header-based authentication. Until migration is complete: - Redact the `token` parameter from access logs and telemetry. - Prevent complete request URLs from being included in exceptions or diagnostics. - Restrict access to proxy, application, and observability logs. - Use short-lived, narrowly scoped, and readily revocable tokens. 7. Update `SKILL.md` so the documented command does not pass credentials on the command line and clearly states that target URLs may also contain sensitive query data. ]]>
