T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:68- Finding
AI-HIVE bearer credential can be transmitted to an arbitrary server by the image-generation client
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:68-99, 132-143
Vulnerability Type: Arbitrary authenticated API destination
Risk Level: HighVulnerable Code
python def _resolve_api_key(self, cli_key): if cli_key: return cli_key env_key = os.environ.get("AI_HIVE_API_KEY") if env_key: return env_key file_config = self._read_config_file() if file_config.get("api_key"): return file_config["api_key"] def _resolve_base_url(self, cli_url): if cli_url: return cli_url.rstrip("/") env_url = os.environ.get("AI_HIVE_BASE_URL") if env_url: return env_url.rstrip("/") file_config = self._read_config_file() if file_config.get("base_url"): return file_config["base_url"].rstrip("/") return DEFAULT_BASE_URLpython def __init__(self, config): self.config = config self.base = config.base_url self.headers = { "Authorization": f"Bearer {config.api_key}", "Content-Type": "application/json", } def _url(self, path): return f"{self.base}/openapi/v1/{path}" def _request(self, method, url, **kwargs): self.config.log(f"{method} {url}") try: resp = requests.request( method, url, headers=self.headers, timeout=DEFAULT_TIMEOUT, **kwargs )Technical Analysis
The client permits the API destination to be supplied through the
--base-urlargument, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. It does not require HTTPS or verify that the hostname belongs to AI-HIVE.Every API request made through
_requestautomatically includes the resolved API key in theAuthorizationheader. Consequently, redirecting the base URL to an attacker-controlled endpoint causes the legitimate bearer credential to be disclosed. A malicious API response can also provide an attacker-controlled media upload URL, allowing user-selected reference media to be sent outsi ...[truncated 1112 chars]- Remediation
View remediation
Remediation Suggestions
- Remove custom base-URL support from the production Skill wrapper if it is not operationally required.
- Otherwise, require HTTPS and enforce an exact hostname allowlist for
ai-hive.iclip.cn. - Resolve and validate the final destination before attaching the bearer credential.
- Disable cross-origin redirects or strip the
Authorizationheader whenever the origin changes. - Validate upload-token URLs against an explicit allowlist of approved object-storage domains and HTTPS schemes.
- Do not trust a base URL loaded from a writable configuration file without validation.
- Check that the configuration file is a regular file owned by the current user and is not a symbolic link before reading credentials from it.
- Add automated tests confirming that credentials are never sent to unapproved hosts.
- Rotate any API key that may previously have been used with an untrusted base URL.
