T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:94- Finding
API credentials can be transmitted to an arbitrary endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:94-100, 130-143; duplicated inscripts/videogen.py:94-100, 130-143
Vulnerability Type: Unrestricted 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 )Technical Analysis
The API base URL may be supplied through the
--base-urlcommand-line option, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The value is used without validating its scheme or hostname.Every request made through
_request()includes the AI-HIVE bearer credential. Consequently, a malicious or accidentally modified endpoint can receive the credential. Anhttp://endpoint would additionally expose the credential to interception over plaintext transport.The same implementation is present in both image and video generation clients, so either script can trigger the issue.
Attack Path
- An attacker influences the command line, process environment, or
~/.ai-hive/config.json. - The attacker sets the base URL to an endpo ...[truncated 747 chars]
- An attacker influences the command line, process environment, or
- Remediation
View remediation
Remediation Suggestions
- Require an HTTPS URL and reject plaintext HTTP endpoints.
- Allowlist
ai-hive.iclip.cnas the credential-bearing production host. - If custom endpoints are required for development, place them behind an explicit opt-in option and require interactive confirmation.
- Parse the URL with
urllib.parse.urlparse()and reject embedded credentials, unexpected ports, fragments, malformed hosts, and non-HTTPS schemes. - Do not attach the bearer credential when the destination host differs from the approved API host.
- Disable redirects or validate every redirect destination before forwarding credentials.
- Warn when configuration-file ownership or permissions are unsafe, rather than relying only on post-read permission tightening.
- Apply the same correction to both
scripts/imagegen.pyandscripts/videogen.py.
