T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:72- Finding
API Credential Exposed Through Command-Line Arguments and URL Query Parameters
- Content
View full analysis
"}' ``` The operation manifest declares the token as a required query parameter: ```js { "defaultValue": null, "description": "User authentication token.", "enumValues": [], "location": "query", "name": "token", "required": true, "schemaType": "string" } ``` The token is injected into the request parameters, appended to the URL, and transmitted: ```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, }; let response; try { response = await fetch(url, requestInit); } catch (error) { fail("Network request failed.", { cause: error instanceof Error ? error.message : String(error), operationId: operation.operationId, }); } ``` ```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; } ``` ```js function applyQueryParams(operation, params, url) { f ...[truncated 3375 chars]- Remediation
View remediation
"}' ``` 5. If the upstream API exclusively supports query-string authentication: - Document the residual URL-logging risk. - Use short-lived, narrowly scoped tokens. - Ensure access logs, proxy logs, tracing systems, and error reports redact the `token` parameter. - Disable unnecessary URL capture in monitoring systems. - Rotate the token promptly after suspected exposure. - Avoid printing or returning the constructed URL in errors. 6. Add automated tests verifying that secrets do not appear in process arguments generated by documentation, request URLs where header authentication is supported, standard output, standard error, or application logs. ]]>
