T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:92- Finding
Bearer Credential Can Be Redirected to an Arbitrary API Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:92-98, 130-143, 586-587;scripts/videogen.py:92-98, 130-143, 586-587
Vulnerability Type: Unrestricted authenticated endpoint 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 self.headers = { "Authorization": f"Bearer {config.api_key}", "Content-Type": "application/json", } 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})")The same implementation is present in both image and video generation scripts.
Technical Analysis
The scripts obtain the API base URL from a command-line argument, the
AI_HIVE_BASE_URLenvironment variable, or the local configuration file. They do not require HTTPS, validate the destination hostname, or confirm that the configured endpoint is controlled by AI-HIVE.The client then attaches the AI-HIVE API key as a bearer credential to every request made through that base URL. Consequently, endpoint selection and credential destination are controlled by configuration that may be modified independently of the credential.
This violates the principle that bearer credentials must be scoped to trusted origins. Because bearer tokens do not provide destination binding, any server receiving the header can reuse the credential.
Attack Path
- An a ...[truncated 1248 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin authenticated requests to the official HTTPS origin by default:
- Scheme:
https - Hostname:
ai-hive.iclip.cn - Expected API path prefix:
/api
- Scheme:
- Reject URLs using plaintext HTTP, embedded credentials, unexpected ports, or unapproved hostnames.
- If custom endpoints are a legitimate requirement, require an explicit high-friction option such as
--allow-custom-endpoint. - Display the destination hostname and require confirmation before sending an existing credential to a non-default endpoint.
- Use separate credentials for custom endpoints rather than automatically reusing the AI-HIVE key.
- Apply the same validation after redirects, or disable cross-origin redirects for authenticated requests.
- Add automated tests covering malicious environment variables, configuration-file overrides, HTTP URLs, look-alike domains, and redirect-based credential leakage.
- Advise affected users to revoke and rotate any API key that may already have been sent to an untrusted endpoint.
- Pin authenticated requests to the official HTTPS origin by default:
