T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:81- Finding
API Credential Disclosure Through an Unrestricted Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 81–91, 127–145, and 511–514
Vulnerability Type: Bearer-token disclosure through a user-controlled API endpoint
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 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 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 API base URL can be supplied through the
--base-urlcommand-line option, theAI_HIVE_BASE_URLenvironment variable, or the local configuration file. The value is accepted without validating its scheme or hostname.The HTTP client independently creates an
Authorization: Bearerheader containing the AI Hive API key and sends that header to every URL built from the selected base URL. Consequently, selecting an attacker-controlled host causes the legitimate API credential to be transmitted ...[truncated 1686 chars]- Remediation
View remediation
Remediation Suggestions
- Restrict authenticated requests to an explicit allowlist of trusted HTTPS origins, such as
https://ai-hive.iclip.cn. - Parse the URL with
urllib.parse.urlparseand reject:- Any scheme other than
https. - URLs containing embedded credentials.
- Unapproved hostnames or ports.
- Ambiguous, malformed, or relative URLs.
- Any scheme other than
- Do not attach the AI Hive bearer token to custom endpoints. If custom servers must be supported, require a separate credential explicitly associated with that origin.
- Disable cross-origin redirects for authenticated requests, or verify every redirect destination before forwarding the
Authorizationheader. - Prefer removing
--base-urlandAI_HIVE_BASE_URLfrom the end-user Skill interface unless custom endpoints are essential. - Treat the configuration file as untrusted input even though its permissions are tightened.
- Add tests confirming that HTTP endpoints, lookalike domains, subdomain tricks, embedded credentials, and cross-origin redirects cannot receive the API key.
- Restrict authenticated requests to an explicit allowlist of trusted HTTPS origins, such as
