T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:76- Finding
API Credential Disclosure Through an Unrestricted Custom Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 76–85 and 134–147
Vulnerability Type: Unrestricted credential forwarding to a user-configurable 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
The API base URL can be supplied through the
--base-urlcommand-line option, theAI_HIVE_BASE_URLenvironment variable, or the local configuration file. The application accepts this value without validating its URL scheme or destination host.AiHiveClientunconditionally attaches the AI Hive API key as a bearer token to requests constructed from that configurable base URL. Consequently, selecting a non-AI-Hive endpoint causes the secret to be transmitted to an arbitrary server. Plain HTTP is also accepted, allowing credentials and request data to be exposed through network interception.This is an insecure trust-boundary design: a credential scoped for AI Hive is forwarded to a destination that has not been authenticated as AI Hive.
Attack Path
- An attacker convinces a user ...[truncated 1340 chars]
- Remediation
View remediation
Remediation Suggestions
- Restrict normal operation to the fixed, trusted AI Hive HTTPS origin.
- Parse the configured URL with a standard URL parser and reject:
- Plain HTTP.
- Embedded user information.
- Unexpected ports.
- Hosts outside an explicit allowlist.
- Ambiguous or malformed hostnames.
- Never attach the AI Hive bearer token when the destination origin differs from the approved API origin.
- If custom endpoints are required for development, gate them behind an explicit development-only option and display a high-friction warning before sending credentials.
- Prefer a separate, endpoint-specific credential for development servers rather than forwarding production API keys.
- Add automated tests confirming that credentials are not sent to unapproved hosts or across HTTPS-to-HTTP redirects.
- Disable redirects for authenticated requests or validate every redirect destination before preserving the
Authorizationheader.
