T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:94- Finding
API Bearer Credential Can Be Transmitted to an Arbitrary or Plaintext Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py:94-101, 128-143
Vulnerability Type: Unrestricted credential destination and insecure transport configuration
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 )Technical Analysis
The API base URL may be supplied through the
--base-urlcommand-line argument, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The implementation does not validate the URL scheme or restrict the destination hostname.The HTTP client then unconditionally attaches the AI Hive bearer credential to every API request made through that base URL. Consequently, an attacker able to influence command-line arguments, environment variables, or
~/.ai-hive/config.jsoncan redirect authenticated requests to an attacker-controlled server. Anhttp://endpoint can also expose the credential to network interception because transport encryption is not required.Custom endpoints may be useful for development, but forwarding a production credential to an unrestricted endpoint ...[truncated 1279 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
https://for all API base URLs and reject plaintext HTTP. - Allowlist the official API hostname,
ai-hive.iclip.cn, for normal operation. - If custom endpoints are required for development, require an explicit unsafe-development flag and display a prominent warning before sending credentials.
- Do not attach the production bearer token when the destination origin differs from the trusted API origin.
- Parse URLs with
urllib.parse.urlparseand validate the normalized scheme, hostname, and port rather than using string-prefix checks. - Consider separating credentials by endpoint so development servers cannot receive production keys.
- Protect the environment and configuration file from untrusted modification and document that
AI_HIVE_BASE_URLis security-sensitive. - Revoke and rotate any API key that may already have been sent to an untrusted endpoint.
- Require
