T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/gen.py:60
- Finding
- Configurable API Endpoint Can Expose the API Key and User Content<![CDATA[ ## Vulnerability Details **File Location**: `scripts/gen.py`, lines 60-75 and 196-197 **Vulnerability Type**: Unrestricted transmission of credentials and user content to a configurable endpoint **Risk Level**: High ### Vulnerable Code ```python def request_generate( base_url: str, api_key: str, prompt: str, model: str, response_format: str, size: str = "", aspect_ratio: str = "", count: int = 1, ) -> dict: """POST /images/generations""" url = f"{base_url.rstrip('/')}/images/generations" payload = { "model": model, "prompt": prompt, "n": count, "response_format": response_format, } if size: payload["size"] = size if aspect_ratio: payload["aspect_ratio"] = aspect_ratio body = json.dumps(payload).encode("utf-8") req = urllib.request.Request( url, method="POST", headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}, data=body, ) ``` ```python api_key = os.environ.get("VVMAI_API_KEY", "").strip() base_url = os.environ.get("VVMAI_BASE_URL", "https://api.vvmai.com/v1").strip() ``` The same endpoint construction and bearer-token transmission pattern is also used by `request_edit`, where an input image is included in the request. ### Technical Analysis The Skill legitimately needs to transmit an API key and prompt to the declared VVMAI image-generation service. However, `VVMAI_BASE_URL` is accepted without validating its scheme or destination host. Consequently, the bearer credential and request content can be sent to any configured host, including a plaintext HTTP endpoint. This exceeds the minimum network privilege needed for the default functionality. A Skill intended to access VVMAI only needs access to VVMAI's authenticated HTTPS endpoint. Supporting arbitrary endpoints without an explicit trust boundary allows a modified environment or configuration file to redirect sensitive requ ...[truncated 1370 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require HTTPS for all API endpoints and reject `http://` or other schemes. 2. Restrict the default configuration to the documented VVMAI hostname, such as `api.vvmai.com`. 3. If custom OpenAI-compatible endpoints are necessary, require explicit opt-in and display a warning that the API key and content will be sent to the selected host. 4. Do not send a VVMAI credential to a host outside an approved allowlist. Use separate credentials for custom providers. 5. Parse the endpoint with `urllib.parse.urlsplit` and validate the normalized scheme, hostname, port, user-information component, and final redirect destination. 6. Disable cross-host redirects for authenticated requests or strip the `Authorization` header whenever a redirect changes the origin. 7. Document clearly that prompts and edit images leave the local system and identify the receiving service. ]]>
