T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:91- Finding
API Credential Disclosure Through an Unrestricted Custom Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py:91-100, 130-149, 587
Vulnerability Type: Server-side credential forwarding to an untrusted 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 parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})")Technical Analysis
The application accepts the API base URL from a command-line argument, environment variable, or configuration file without validating its scheme or hostname. The HTTP client subsequently adds the AI Hive API key to every API request as an
Authorization: Bearerheader.Consequently, any URL supplied through
--base-url,AI_HIVE_BASE_URL, or~/.ai-hive/config.jsonbecomes a credential recipient. The implementation permits plaintext HTTP and arbitrary external hosts. An attacker who can influence a command, environment variable, or configuration file can redirect authenticated requests to an attacker-controlled server.Attack Path
- The attacker convinces the user to run the skill with a ...[truncated 972 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse the configured URL with
urllib.parse.urlparse. - Require the
httpsscheme and reject embedded credentials, fragments, unexpected ports, and malformed hostnames. - Allowlist
ai-hive.iclip.cnfor normal operation. - If custom API endpoints are genuinely required, require a separate explicit opt-in option and interactive confirmation before sending credentials.
- Do not automatically reuse the production API key with custom hosts. Require a separately supplied credential for non-default endpoints.
- Reject redirects to hosts outside the approved allowlist, or disable redirects for authenticated API requests.
- Apply equivalent validation to command-line, environment-variable, and configuration-file values.
- Parse the configured URL with
