T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/wangyi-banana.py:153
- Finding
- API Key Exposure Through Command-Line Arguments and Insecure Setup Guidance<![CDATA[ ## Vulnerability Details **File Location**: `scripts/wangyi-banana.py:153-177` **Additional Locations**: `scripts/wangyi-banana.py:637`, `install.md:46`, `references/api-key-setup.md:82-84` **Vulnerability Type**: Sensitive credential exposure **Risk Level**: Medium ### Vulnerable Code ```python url = f"{DEFAULT_HOST}{endpoint_suffix}" headers = { "Authorization": f"Bearer {api_key}", } if not is_form_data: headers["Content-Type"] = "application/json" max_retries = 3 last_error: dict | None = None for retry in range(max_retries): try: if is_form_data: result = curl_post_form_data(url, payload, headers, timeout) else: if method == "POST": result = curl_post_json(url, payload, headers, timeout) else: # GET cmd = [ "curl", "-s", "-S", "--fail-with-body", "-X", "GET", url, "--max-time", str(timeout), ] for k, v in headers.items(): cmd += ["-H", f"{k}: {v}"] result = subprocess.run(cmd, capture_output=True, text=True) ``` The command-line API-key option is also declared as follows: ```python parser.add_argument("--api-key", "-k", help="API key (optional, resolved from config)") ``` The setup documentation additionally advises users that they may provide an API key directly in a conversation. ### Technical Analysis The bearer token is incorporated into the argument vector of each spawned `curl` process through the `Authorization` header. Depending on the operating system and execution environment, command arguments may be visible through process inspection interfaces, monitoring agents, diagnostic tooling, crash collection, or audit logs. A local actor with sufficient process-observation access could recover the complete API key while a request is active. The `--api-key` option creates a second exposure path because command-line invocations m ...[truncated 1860 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove guidance that asks users to send API keys through chat. Direct users to a trusted secret-management interface or a permission-restricted environment configuration instead. 2. Deprecate and remove the `--api-key` command-line option. If temporary credential input is necessary, read it from a protected file descriptor, secret store, or non-echoing interactive prompt. 3. Avoid placing authorization headers in child-process arguments. Prefer an in-process HTTPS client so credentials remain within process memory. 4. If `curl` must be retained, provide sensitive configuration through standard input or a temporary configuration file with mode `0600`, and securely delete that file immediately after use. 5. Ensure temporary files are created in a private directory with restrictive permissions and are never included in diagnostics. 6. Redact authorization headers and API-key values from application logs, subprocess errors, telemetry, and exception reports. 7. Restrict the API key to only the endpoints and spending limits required for image and video generation. 8. Add credential rotation and revocation instructions for users who previously supplied keys through chat or command-line arguments. ]]>
