T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:89- Finding
Bearer API Key Can Be Transmitted to an Arbitrary Configured Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py:89-101, 127-143
Vulnerability Type: Unrestricted credential destination and missing transport validation
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 class AiHiveClient: """封装 AI Hive OpenAPI HTTP 调用。""" 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 can be supplied through the
--base-urlargument, theAI_HIVE_BASE_URLenvironment variable, or the configuration file. The value is accepted without validating its scheme or hostname.The HTTP client subsequently adds the AI Hive bearer API key to every API request made through that base URL. Consequently, an arbitrary endpoint—including a plaintext HTTP endpoint or an attacker-controlled HTTPS host—can receive the credential.
This is particularly dangerous when commands or configuration files are copied from untrusted sources, or when environment variables are controlled by a wrapper script, CI configuration, or compromised parent process. Although chang ...[truncated 1382 chars]
- Remediation
View remediation
Remediation Suggestions
- Allowlist the official API scheme and hostname by default:
- Require
https. - Require the hostname to equal
ai-hive.iclip.cn. - Reject embedded credentials, unexpected ports, fragments, and malformed URLs.
- Require
- If custom endpoints are required for development, place them behind an explicit option such as
--allow-custom-base-url. - Display the normalized destination hostname and require interactive confirmation before sending credentials to a nonofficial host.
- Refuse plaintext HTTP whenever an authorization header is present.
- Consider separating official API operation from custom endpoint operation so that production credentials are never automatically reused with development servers.
- Document that base URL settings must not be copied from untrusted commands or configuration files.
- Add automated tests confirming that HTTP URLs, lookalike domains, hostname suffix tricks, and credential-bearing URLs are rejected.
- Allowlist the official API scheme and hostname by default:
