T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:187- Finding
API Key Exposure Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:45-53,bin/run.mjs:104-105,bin/run.mjs:118-121, andbin/run.mjs:187-190
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: MediumVulnerable Code
bash node {baseDir}/bin/run.mjs --operation "immersiveProduct" --api-key "$JUST_SERP_API_KEY" --params-json '{"page_token":"<page_token>"}'js if (!args.apiKey) { fail("Missing required --api-key argument."); }js const requestInit = { headers: { "accept": "application/json", "X-API-Key": args.apiKey, }, method: operation.method, };js if (flag === "--api-key") { parsed.apiKey = value; index += 1; continue; }Technical Analysis
The documented invocation expands
JUST_SERP_API_KEYinto the Node process argument vector. The argument parser then requires and consumes the key through--api-key.Command-line arguments may be captured by process-inspection interfaces, monitoring or observability agents, shell auditing, diagnostic reports, and command-history mechanisms. Consequently, the documentation's warning not to paste or log the key does not prevent disclosure through the process command line itself.
This issue requires an attacker or monitoring system capable of observing command invocation data. It does not independently grant remote code execution or elevated operating-system privileges.
Attack Path
- A user follows the documented command and invokes the helper with
--api-key "$JUST_SERP_API_KEY". - The shell expands the environment variable before starting Node, placing the plaintext key in the child process argument vector.
- A local user, privileged process-monitoring service, audit facility, or diagnostic collector records or reads the command-line arguments.
- The observer extracts the API key.
- The observer submits the stolen key in the
X-API-Keyheader to Just Serp API endpoints. - The observer can consume the v ...[truncated 573 chars]
- A user follows the documented command and invokes the helper with
- Remediation
View remediation
Remediation Suggestions
- Read the credential directly from the process environment rather than accepting it as a command-line argument:
js const apiKey = process.env.JUST_SERP_API_KEY; if (!apiKey) { fail("Missing required JUST_SERP_API_KEY environment variable."); }- Use the environment-derived value when constructing the request:
js const requestInit = { headers: { accept: "application/json", "X-API-Key": apiKey, }, method: operation.method, };- Remove or deprecate
--api-keyhandling so secrets cannot accidentally be supplied in process arguments. - Update the documented invocation to omit the credential argument:
bash JUST_SERP_API_KEY="..." node {baseDir}/bin/run.mjs \ --operation "immersiveProduct" \ --params-json '{"page_token":"<page_token>"}'- Where environment visibility is also a concern, support credential input through a protected file descriptor, standard input, or an operating-system secret manager.
- Ensure errors, debug output, telemetry, and request logging never serialize the API key or complete request headers.
- Rotate any key suspected of having been captured by process monitoring, command auditing, or diagnostic tooling.
