T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:91- Finding
Unrestricted API Base URL Override Can Disclose Credentials and User Media
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 91-101, 125-143, 266-305, and 585-588
Vulnerability Type: Unvalidated external service endpoint
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 )python media_id = token["mediaId"] upload_url = token["upload"]["url"] upload_method = token["upload"].get("method", "PUT") upload_headers = token["upload"].get("headers", {}) # PUT 到 OSS — 不携带 API Key,使用返回的 headers print(f"[2/3] 上传文件到对象存储...") with open(str(path), "rb") as f: try: oss_resp = requests.request( upload_method, upload_url, headers=upload_headers, data=f, timeout=300, )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_BASE_URL})") parser.add_argument("--verbose", action="sto ...[truncated 2551 chars]- Remediation
View remediation
Remediation Suggestions
- Remove
--base-urlandAI_HIVE_BASE_URLoverrides from the production Skill interface unless custom deployments are a documented requirement. - Allow-list the expected API hostname, such as
ai-hive.iclip.cn, and require anhttpsURL with an expected port. - If custom endpoints must remain supported, require an explicit high-friction confirmation before sending credentials and clearly display the target origin.
- Use separate credentials for custom endpoints rather than sending the production AI Hive key to arbitrary configured hosts.
- Validate every upload and download URL returned by the API. Require HTTPS and restrict destinations to approved object-storage hostnames.
- Reject URL user information, unexpected ports, redirects to untrusted hosts, and non-HTTP methods not required by the upload protocol.
- Consider disabling automatic redirects or revalidating the destination after every redirect to prevent allow-list bypass.
- Document that selected media is transmitted to an external generation service and obtain appropriate user approval before uploading sensitive business assets.
- Remove
