T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:75- Finding
API Credential Disclosure Through an Unrestricted Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py:75-84,scripts/videogen.py:123-138, andscripts/videogen.py:859-860
Vulnerability Type: Credential disclosure through an attacker-controlled 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 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 )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 {DEFAULT_BASE_URL})") parser.add_argument("--verbose", action="store_true", help="Detailed logs")Technical Analysis
The API base URL can be supplied through the
--base-urlargument, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The value is accepted without validating its scheme, hostname, port, embedded user information, or trust relationship with the API key.AiHiveClientautomatically places th ...[truncated 2060 chars]- Remediation
View remediation
Remediation Suggestions
- Remove custom base URL support if alternate API endpoints are not required.
- If custom endpoints are necessary, parse URLs with
urllib.parse.urlsplitand require:- The
httpsscheme. - An explicit allowlist of trusted hostnames.
- No embedded username or password.
- Approved ports only.
- The
- Bind stored credentials to the origin for which they were created. Do not send the default AI Hive key to any other origin.
- Require explicit interactive confirmation before using a stored credential with a non-default endpoint.
- Require users to provide a separate credential explicitly when using a custom endpoint.
- Disable or carefully validate cross-origin redirects so authorization headers cannot reach an unintended host.
- Add automated tests that verify rejection of HTTP URLs, look-alike domains, URL user information, unapproved ports, and attacker-controlled hosts.
- Document the trust implications of endpoint overrides and recommend immediate key rotation if a key has been sent to an untrusted endpoint.
