T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:91- Finding
Arbitrary API Base URL Can Disclose the AI Hive API Key
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 91-100 and 128-143
Vulnerability Type: Unrestricted credential-bearing network 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 unrestricted endpoint is exposed through both the command line and the environment:
python def add_common_args(parser): parser.add_argument("--api-key", help="AI Hive API Key (sk-api-*)") parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})") parser.add_argument("--verbose", action="store_true", help="Verbose logging")Technical Analysis
The application accepts an arbitrary API base URL from
--base-url,AI_HIVE_BASE_URL, or the local configuration file. It performs no scheme validation, hostname allowlisting, or confirmation before attaching the AI Hive API key as anAuthorization: Bearerheader.Consequently, the destination can be an attacker-controlled HTTPS host or even a plaintext HTTP endpoint. The API key is then transmitted to that destination wh ...[truncated 1774 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
--base-urlandAI_HIVE_BASE_URLif custom endpoints are not essential to the declared Skill. - Allowlist the expected HTTPS origin, such as
https://ai-hive.iclip.cn. - Parse endpoints with
urllib.parse.urlparseand reject:- Any scheme other than HTTPS.
- URLs containing embedded user information.
- Unexpected hostnames or ports.
- Fragments or malformed authority components.
- Never attach the AI Hive Bearer token to an endpoint outside the approved origin.
- If custom enterprise endpoints are a legitimate requirement, require explicit interactive confirmation before transmitting credentials and use separately scoped credentials for each origin.
- Treat changes to the configured endpoint as security-sensitive and display the exact destination before making an authenticated request.
- Document immediate key revocation and rotation procedures for users who may have sent a key to an untrusted endpoint.
- Remove
