T09 · Insecure Skill Coding Practices
- Location
bin/run.mjs:223- Finding
API Key Exposed Through Process Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:49,57;bin/run.mjs:139-141,156,223-226
Vulnerability Type: API credential exposure through process arguments
Risk Level: MediumThe documented invocation passes the Just Serp API key through the
--api-keycommand-line argument:bash node {baseDir}/bin/run.mjs --operation "jobsSearch" --api-key "$JUST_SERP_API_KEY" --params-json '{"query":"<query>"}'The script requires, parses, and uses that argument as follows:
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
Although the documentation obtains the credential from the
JUST_SERP_API_KEYenvironment variable, the shell expands"$JUST_SERP_API_KEY"before starting Node.js. The plaintext credential consequently becomes part of the process argument vector.Process arguments may be visible through operating-system process inspection interfaces, diagnostic utilities, monitoring agents, crash reports, audit logs, or command telemetry. An observer with sufficient local process-inspection access could capture the API key while the helper is running. The documentation's warning not to place the key in logs does not prevent this exposure because the recommended command itself transfers the secret into
argv.Attack Path
- A user stores a valid Just Serp API credential in
JUST_SERP_API_KEY. - The user invokes the helper using the command documented in
SKILL.md. - The shell expands the environment variable and places the plaintext key after
--api-keyin the Node.js process argument vector. - A local process observer, privileged monitoring component, or diagnost ...[truncated 694 chars]
- A user stores a valid Just Serp API credential in
- Remediation
View remediation
Remediation Suggestions
-
Read the credential directly from the environment instead of accepting it through 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
--api-keyhandling fromparseArgsso callers cannot inadvertently expose credentials throughargv. -
Update the documented invocation to omit the credential argument:
bash JUST_SERP_API_KEY="$JUST_SERP_API_KEY" node {baseDir}/bin/run.mjs \ --operation "jobsSearch" \ --params-json '{"query":"<query>"}' -
If explicit secret input is required, accept it through protected standard input, a dedicated secret manager, or a permission-restricted credential file rather than command-line arguments.
-
Avoid logging request headers, environment variables, or credential-bearing configuration. Redact
X-API-Keyin diagnostic and error-reporting systems.
-
