T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:91- Finding
Unrestricted API endpoint override can disclose bearer credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:91-99, 130-143;scripts/videogen.py:91-99, 130-143
Vulnerability Type: Arbitrary credential-bearing API endpoint
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 )The same endpoint resolution and request behavior appears in both
imagegen.pyandvideogen.py.Technical Analysis
The API base URL can be supplied through the
--base-urlcommand-line option, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The supplied value is accepted without validating its scheme or hostname.The client subsequently adds the AI-HIVE API key to the
Authorizationheader of every request sent to that base URL. Consequently, a custom endpoint can receive the bearer credential. The code also permits an unencryptedhttp://endpoint, which could expose the credential to network interception.Exploitation requires an attacker to influence the command line, environment, or
~/.ai-hive/config.json. This could occur through malicious setup instructions, a poisoned shell environment, or unauthorized modific ...[truncated 1310 chars]- Remediation
View remediation
Remediation Suggestions
- Require HTTPS for all API endpoints and reject URLs using plaintext HTTP or other schemes.
- Allowlist the official AI-HIVE hostname by default.
- If custom endpoints are a required feature, require explicit informed confirmation before sending credentials to a nonofficial host.
- Store credentials per endpoint rather than automatically reusing an AI-HIVE credential for every configured base URL.
- Parse URLs with a standard URL parser and reject embedded credentials, malformed hosts, ambiguous hostnames, and unexpected ports.
- Consider removing the base URL override from normal user-facing commands or gating it behind a clearly named development-only option.
- Document that users must revoke and rotate the API key immediately if it may have been sent to an untrusted endpoint.
