T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:61- Finding
Configurable API Base URL Can Expose the Bearer API Key to an Untrusted Server
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 61–143
Vulnerability Type: Unrestricted credential-bearing network destination
Risk Level: MediumVulnerable Code
python class Config: """Three-level priority for API Key and Base URL: CLI, environment, config file.""" def __init__(self, api_key=None, base_url=None, verbose=False): self.verbose = verbose self.api_key = self._resolve_api_key(api_key) self.base_url = self._resolve_base_url(base_url) 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: """AI Hive OpenAPI HTTP client.""" 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 destination can be supplied through the
--base-urlcommand-line option, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. These values are accepted without validating the URL scheme or destination hostname.The same configuration object independently obtains the user's AI-HIVE API key. `AiHiveCl ...[truncated 1999 chars]
- Remediation
View remediation
Remediation Suggestions
- Restrict the production endpoint: Default to and allow only
https://ai-hive.iclip.cn/apifor ordinary Skill execution. - Enforce HTTPS: Reject plaintext HTTP and unsupported URL schemes before constructing the client.
- Use a hostname allowlist: If alternate deployments are necessary, permit only explicitly documented and trusted hostnames.
- Require explicit approval: Display the destination hostname and require interactive confirmation before sending credentials to any non-default endpoint.
- Separate credentials by origin: Do not attach the AI-HIVE bearer token to an endpoint whose origin does not match the trusted service origin.
- Harden configuration handling: Validate
base_urlwhen reading the configuration file and reject embedded credentials, unexpected ports, malformed URLs, and unapproved hosts. - Reduce environment-based overrides: Consider disabling
AI_HIVE_BASE_URLin production mode or requiring an explicit development flag before honoring it. - Add security tests: Verify that untrusted schemes and hostnames are rejected and that authorization headers are never sent outside the approved origin.
- Restrict the production endpoint: Default to and allow only
