T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:31- Finding
API Credential Exposed Through Command-Line Arguments and URL Query Parameters
- Content
View full analysis
"}' ``` `bin/run.mjs:31-38` declares the credential 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:65-67` adds all query parameters, including the token, to the request URL: ```js applyPathParams(operation, params, url); applyQueryParams(operation, params, url); ``` `bin/run.mjs:187-197` copies the command-line 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:223-233` serializes query parameters 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); } } ``` The generated API documentation repeats the same query-token contract in `generated/operations.json:14-22`: ```json { "defaultValue": null, "description" ...[truncated 3311 chars]- Remediation
View remediation
"}' ``` 2. **Use an authentication header if the provider supports it.** Prefer a standard header such as: ```js requestInit.headers.authorization = `Bearer ${token}`; ``` Do not add the token to `URL.searchParams`. 3. **If the API currently requires query-string authentication, request or implement a provider-side authentication-header option.** Until that is available: - Read the token from the environment rather than the command line. - Configure clients, gateways, proxies, observability tools, and servers to redact the `token` query parameter. - Disable query-string capture where operationally possible. - Ensure error messages and diagnostics never print the fully constructed URL. - Use short-lived, narrowly scoped tokens with restrictive quotas. 4. **Prevent alternate token injection through `--params-json`.** Reject a caller-provided `params.token` and source credentials only from the designated secure mechanism. This avoids accidental token inclusion in shell history or application logs. 5. **Rotate potentially exposed credentials.** Tokens previously used through command arguments or logged query strings should be revoked and replaced after relevant logs and telemetry are reviewed. 6. **Update all generated metadata and documentation.** Keep `SKILL.md`, `generated/operations.json`, and `generated/operations.md` consistent with the hardened authentic ...[truncated 99 chars]
