T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/generate_image.py:185
- Finding
- API Key Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate_image.py:185-188` and `scripts/generate_image.py:214-218`; unsafe usage is also documented in `SKILL.md:110` **Vulnerability Type**: Credential exposure through process arguments **Risk Level**: Medium ### Complete Code Snippet ```python parser.add_argument( "--api-key", help="APIYI API key (override all other sources)" ) ``` ```python # Get API key # Priority: # 1) CLI --api-key # 2) openclaw.json top-level env.APIYI_API_KEY (requested behavior) # 3) OS env var APIYI_API_KEY (fallback) api_key = args.api_key api_key_source = "cli" if api_key else None ``` The documentation explicitly presents this method as supported: ```markdown Or use `--api-key` flag directly. ``` ### Technical Analysis The Skill accepts a long-lived API credential as a command-line argument. Process arguments are not an appropriate secret-transport mechanism because they may be exposed through: - Shell history files. - Process inspection utilities and operating-system process metadata. - Job runners, monitoring agents, audit systems, and diagnostic logs. - Command transcripts copied into support tickets or chat sessions. The API key is legitimately required to authenticate to APIYI, but exposing it through `argv` exceeds the minimum privilege and disclosure necessary for image generation. The existing environment-variable and configuration-file mechanisms can provide the credential without placing it directly in the command invocation. The script does not intentionally transmit the key to an unrelated endpoint. It uses the key as a Bearer token only for the declared APIYI service. The vulnerability is the local exposure created before the request is sent. ### Attack Path 1. A user follows the documented option and invokes the script with `--api-key sk-...`. 2. The complete command is recorded in shell history, process telemetry, CI logs, or another local observability system. 3. A local user, adminis ...[truncated 859 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--api-key` argument, or mark it as deprecated and reject its use after a migration period. 2. Retrieve the key from `APIYI_API_KEY`, a credential manager, secure standard input, or a configuration file with restrictive permissions. 3. Correct the documentation so it does not recommend placing credentials in command-line arguments. 4. Align the documented configuration layout with the path actually read by the script. `SKILL.md` documents `skills.nano-banana2-apiyi.apiKey`, while the implementation reads top-level `env.APIYI_API_KEY`. 5. If a configuration file remains supported, verify that it is owned by the expected user and is not accessible to other users. 6. Advise users who previously supplied keys through `--api-key` to clear affected histories and logs and rotate potentially exposed credentials. ]]>
