T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:92- Finding
Bearer Credential Disclosure Through an Unrestricted API Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:92-100, 128-143; equivalent implementation inscripts/videogen.py:92-100, 128-143
Vulnerability Type: Unvalidated credential destination
Risk Level: HighVulnerable 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 class AiHiveClient: """Encapsulates AI Hive OpenAPI HTTP calls.""" 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 can be supplied through the
--base-urlcommand-line argument, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The value is used without validating its scheme, hostname, port, or origin.The client subsequently attaches the AI-HIVE bearer credential to every request made to that destination. Consequently, an HTTP URL or attacker-controlled HTTPS endpoint can receive the credential. Plain HTTP additionally exposes the credential to network interception.
The same vulnerable client implementation appears in both image and video generation scripts.
Attack Path
- An attacke ...[truncated 1125 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
httpsfor every credential-bearing endpoint and reject plaintext HTTP. - Allowlist the official AI-HIVE API hostname by default.
- If custom endpoints are necessary, require an explicit high-risk opt-in and display the destination before sending credentials.
- Normalize and parse URLs with
urllib.parse.urlparse; reject embedded credentials, unexpected ports, fragments, and malformed hostnames. - Do not attach the bearer token until the destination origin has passed validation.
- Prevent credential forwarding when redirects change the origin.
- Validate persistent configuration ownership and permissions before trusting its
base_url. - Apply the same hardened shared client implementation to both
imagegen.pyandvideogen.py.
- Require
