T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:100- Finding
Arbitrary API Base URL Can Expose the Bearer API Key
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py:100-111, 130-145, 587
Vulnerability Type: Unvalidated credential destination
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 )python parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})")Technical Analysis
The API endpoint can be supplied through a command-line argument, the
AI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The value is accepted without requiring HTTPS or validating the destination host against an allowlist.The HTTP client then attaches the AI Hive bearer token to every request made through that base URL. Consequently, control over any base URL input is equivalent to control over the destination to which the API credential is transmitted.
This is not an automatic compromise under normal use because the legitimate default endpoint is HTTPS. Exploitation requires influence over the invocation, environment, or configuration file. Nevertheless, automation wrappers, copied command ...[truncated 1259 chars]
- Remediation
View remediation
Remediation Suggestions
- Require the base URL to use HTTPS.
- Allowlist the documented production hostname,
ai-hive.iclip.cn, for ordinary operation. - If custom endpoints are necessary for development, require an explicit opt-in flag and display a warning before transmitting credentials.
- Parse URLs with
urllib.parse.urlparseand reject embedded credentials, fragments, malformed hosts, and unexpected ports. - Disable redirects for authenticated API calls or validate every redirect destination before forwarding the Authorization header.
- Consider separating production credentials from credentials permitted for custom development endpoints.
- Protect the configuration directory as well as the configuration file and document that configuration integrity is security-sensitive.
