T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:91- Finding
API credentials can be transmitted to an arbitrary or plaintext endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:91-99, 129-145; duplicated inscripts/videogen.py:91-99, 129-145
Vulnerability Type: Improper validation of a credential-bearing API endpoint
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
Both generation clients accept an unrestricted API base URL from a command-line argument, the
AI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. They then attach the AI-HIVE bearer credential to every request sent to that endpoint.There is no validation that:
- The scheme is HTTPS.
- The destination host is the documented
ai-hive.iclip.cnservice. - Redirects remain on an approved host.
- User information, model queries, task queries, and generation requests are sent only to a trusted service.
Consequently, a malicious or accidentally configured URL can receive the complete API key in the
Authorizationheader. Anhttp://endpoint can additionally expose the credential and submitted data to network interception. Becau ...[truncated 1885 chars]- Remediation
View remediation
Remediation Suggestions
- Remove arbitrary base-URL overrides from production-facing commands unless they are strictly required for development.
- Parse the URL with
urllib.parse.urlsplitand require:scheme == "https"- An exact approved hostname such as
ai-hive.iclip.cn - An expected port and path prefix
- No embedded username or password
- Maintain an explicit endpoint allowlist rather than using suffix-based hostname checks.
- Reject plaintext HTTP whenever an authorization header is present.
- Disable automatic redirects for credential-bearing requests or validate every redirect target before resending authorization.
- Never forward an authorization header across origins.
- If custom endpoints are needed for testing, require a separate explicit development mode and a separate non-production credential.
- Validate a stored
base_urlbefore reading or using the stored API key. - Apply the same remediation to both
scripts/imagegen.pyandscripts/videogen.py. - Revoke and rotate keys used with an untrusted base URL.
