T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:91- Finding
Bearer credentials can be transmitted to an arbitrary API endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:91-100, 130-143; mirrored inscripts/videogen.py:91-100, 130-143
Vulnerability Type: Unrestricted credential-bearing endpoint configuration
Risk Level: MediumVulnerable Code
python 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 API base URL may be supplied through the
--base-urlargument, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The value is accepted without validating its scheme or hostname.The HTTP client subsequently attaches the AI-HIVE bearer credential to every request made through that base URL. Consequently, a configured endpoint does not need to belong to AI-HIVE to receive the credential. The code also permits an unencrypted
http://endpoint, which could expose credentials and request content to a network observer.This behavior exists independently in both image and video generation scripts.
Attack Path
- An attacker influences a command, environment variable, wrapper script, or configuration file used to launch ...[truncated 1222 chars]
- Remediation
View remediation
Remediation Suggestions
- Require the
httpsscheme for every credential-bearing API endpoint. - Allowlist the expected hostname, such as
ai-hive.iclip.cn, in normal operation. - Reject URLs containing embedded credentials, unexpected ports, fragments, or non-HTTPS schemes.
- If custom endpoints are required for development, place them behind an explicit option such as
--allow-unsafe-custom-endpoint. - Display the normalized destination and require confirmation before sending credentials to a nonstandard host.
- Separate credentials by endpoint so that a production AI-HIVE key is never automatically reused with a custom server.
- Apply the same validation to command-line, environment, and configuration-file values.
- Add automated tests covering HTTP URLs, lookalike domains, user-information components, redirects, and malformed hosts.
- Consider disabling automatic redirects for authenticated requests or stripping the authorization header whenever a redirect changes the origin.
- Require the
