T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:122- Finding
API Key Exposed Through Command-Line Arguments
- Content
View full analysis
"}' ``` `SKILL.md:55` repeats this credential transport mechanism: ```markdown - Pass the API key with `--api-key "$JUST_SERP_API_KEY"`; do not paste key values into chat messages, screenshots, or logs. ``` `bin/run.mjs:122-138` consumes that argument and sends it as an authentication header: ```javascript if (!args.apiKey) { fail("Missing required --api-key argument."); } const params = parseParams(args.paramsJson); applyDefaults(operation, params); 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", "X-API-Key": args.apiKey, ``` `bin/run.mjs:191-208` parses the secret directly from the process arguments: ```javascript function parseArgs(argv) { const parsed = { apiKey: null, operation: null, paramsJson: "{}" }; for (let index = 0; index < argv.length; index += 1) { const flag = argv[index]; const value = argv[index + 1]; if (flag === "--operation") { parsed.operation = value; index += 1; continue; } if (flag === "--params-json") { parsed.paramsJson = value; index += 1; continue; } if (flag === "--api-key") { parsed.apiKey = value; index += 1; ``` ### Technical Analysis The shell expands `$JUST_SERP_API_KEY` before launching Node.js, placing the resulting credential in the process argument vector. Depending o ...[truncated 2219 chars]- Remediation
View remediation
"}' ``` If the variable is already exported, omit the redundant assignment: ```bash node {baseDir}/bin/run.mjs \ --operation "newsSearch" \ --params-json '{"query":""}' ``` 4. Never include the key in stdout, stderr, backend error payloads, debug output, or exception diagnostics. 5. Document credential rotation and revocation procedures. Rotate any key suspected of having been exposed through process telemetry. 6. Where available, use a restricted credential provider or protected standard-input mechanism instead of command-line arguments. Scope the API key to only the endpoints and quota required by this Skill. ]]>
