T09 · Insecure Skill Coding Practices
- Location
scripts/generate_image.py:205- Finding
API Key Accepted Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_image.py:205
Vulnerability Type: Exposure of credentials through process arguments
Risk Level: Mediumpython parser.add_argument("--api-key", "-k", help="OpenRouter API key (overrides OPENROUTER_API_KEY)")The corresponding documentation explicitly encourages this credential-passing mechanism at
SKILL.md:44-47:markdown The script checks for API key in this order: 1. `--api-key` argument 2. `OPENROUTER_API_KEY` environment variableTechnical Analysis
Passing an API key as a command-line argument can disclose it through shell history, process listings, operating-system audit records, job metadata, terminal logs, and monitoring systems that capture command invocations. The implementation accepts the key in
--api-keyor-kand subsequently uses it as the OpenRouter bearer credential.Exploitation requires local or administrative access to process metadata, command history, or logs containing the invocation. The script does not print the API key itself, and the reviewed code does not transmit it to any undeclared destination. Nevertheless, supporting command-line credential input creates an avoidable local disclosure channel.
Attack Path
- A user follows the documented workflow and invokes the script with
--api-key SECRET. - The complete invocation is retained in shell history, process metadata, audit logs, task-runner metadata, or monitoring telemetry.
- A local user or service with access to one of those sources retrieves the API key.
- The attacker submits requests to OpenRouter using the exposed bearer credential.
- The attacker consumes the associated quota or exercises any OpenRouter permissions granted to that credential until it is revoked or expires.
Impact Assessment
Successful exploitation exposes the OpenRouter API credential. The resulting privileges are limited to those granted to that key ...[truncated 615 chars]
- A user follows the documented workflow and invokes the script with
- Remediation
View remediation
Remediation Suggestions
- Remove the
--api-keyand-karguments so credentials cannot be placed directly in command invocations. - Prefer a protected secret manager, operating-system keyring, or credential file with restrictive permissions.
- If environment-variable support is retained, document
OPENROUTER_API_KEYas the fallback and warn that environment variables may also be exposed by some process-management or diagnostic systems. - For interactive use, optionally read the key through a non-echoing prompt such as
getpass.getpass()when no protected secret source is configured. - Update
SKILL.mdto remove examples or instructions that recommend--api-key. - Advise users who previously supplied keys on the command line to clear affected histories and logs where feasible and rotate potentially exposed credentials.
- Continue restricting credential transmission to the fixed HTTPS OpenRouter endpoint, and avoid including authorization headers or request objects in diagnostic output.
- Remove the
