T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:91- Finding
API credentials can be transmitted to an arbitrary endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:91-99, 128-143;scripts/videogen.py:91-99, 128-143
Vulnerability Type: Unrestricted API base URL with credential forwarding
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 class AiHiveClient: """Encapsulates AI Hive OpenAPI HTTP calls.""" 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 scripts permit the API base URL to be supplied through a command-line argument, the
AI_HIVE_BASE_URLenvironment variable, or the local configuration file. The value is accepted without validating its scheme or hostname.The client then adds the AI-HIVE Bearer API key to every request made through that base URL. Consequently, an attacker who can influence the command invocation, process environment, or
~/.ai-hive/config.jsoncan redirect authenticated requests to an attacker-controlled service. A URL using plain HTTP would additionally expose the credential to network interception.This is a confused-deputy and credential-d ...[truncated 1623 chars]
- Remediation
View remediation
Remediation Suggestions
- Require the default production endpoint to use HTTPS and validate the parsed URL:
- Scheme must be
https. - Hostname must exactly match an approved AI-HIVE hostname.
- Reject embedded credentials, fragments, and unexpected ports.
- Scheme must be
- Do not send an AI-HIVE credential to arbitrary custom endpoints.
- If custom endpoints are a required development feature:
- Disable them by default.
- Require an explicit unsafe-development flag.
- Require a separate credential for each endpoint.
- Display the destination hostname and request interactive confirmation.
- Avoid allowing security-sensitive endpoint overrides through ambient environment variables in production.
- Add automated tests for plain HTTP, deceptive subdomains, user-info syntax, redirects, and non-allowlisted hosts.
- Review redirect handling and ensure authorization headers cannot be forwarded to an untrusted redirect destination.
- Advise affected users to revoke and rotate any key that may have been used with an untrusted base URL.
- Require the default production endpoint to use HTTPS and validate the parsed URL:
