T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:67
- Finding
- API Key Exposure Through Agent Context and Command-Line Arguments## Vulnerability Details **File Location**: `SKILL.md:67-70` **Vulnerability Type**: Unnecessary secret access and insecure credential transmission **Risk Level**: High ### Vulnerable Code ```text - If `~/.openclaw/workspace/skills/nano-banana-pro-openrouter/.env` exists: 1. Use the `read` tool to read `.env` 2. Extract `OPENROUTER_API_KEY` and `OPENROUTER_BASE_URL` 3. Always pass the key via `--api-key` when running the script ``` ### Technical Analysis The Skill explicitly instructs the Agent to read a credential file, extract the OpenRouter API key into the Agent's context, and pass that secret as a command-line argument. This access exceeds the minimum privileges needed for image generation. The shell script already loads the Skill-local `.env` file itself, so the Agent does not need to read or process the secret. Passing the key using `--api-key` may additionally expose it through process listings, command logging, execution telemetry, shell history, or tool-call records. ### Attack Path 1. A plaintext API key is stored in the Skill's `.env` file. 2. The Skill instructions direct the Agent to read the entire file. 3. The API key enters the Agent and tool execution context. 4. The Agent invokes the script with `--api-key KEY`. 5. The key may become visible in process arguments, tool logs, execution history, or diagnostic output. 6. A party with access to any of these channels can recover and reuse the credential. ### Impact Assessment Successful exploitation may disclose the OpenRouter API key to other local users, monitoring systems, logs, or parties with access to Agent execution records. A stolen key could be used to consume the victim's API quota, incur charges, or access capabilities associated with the affected OpenRouter account. This does not directly grant operating-system privilege escalation.
- Remediation
- ## Remediation Suggestions - Remove the instructions requiring the Agent to read `.env`. - Do not pass API keys through command-line arguments. - Allow the script to read only its trusted Skill-local `.env`, which it already supports. - Alternatively, supply credentials through a protected file descriptor, standard input, or a dedicated secret manager. - Ensure the credential file has restrictive permissions, such as mode `0600`. - Redact authorization data from all execution logs and error reports.
