T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:93- Finding
Unrestricted API endpoint override can disclose the AI-HIVE bearer credential
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 93–104, 128–134, and 488–491
Vulnerability Type: Unvalidated credential-bearing endpoint configuration
Risk Level: MediumVulnerable 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", }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="Verbose logging")Technical Analysis
The client permits its API base URL to be supplied through a command-line argument, the
AI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. No validation requires HTTPS or restricts the destination to an approved AI-HIVE hostname.Every API request generated from this base URL carries the user's bearer credential in the
Authorizationheader. Consequently, configuration of an attacker-controlled endpoint causes the legitimate client to disclose the API key. Allowing an arbitrary endpoint is not necessary for the Skill's declared fixed-purpose integration withhttps://ai-hive.iclip.cn/apiand therefore exceeds least-privilege requirements.The command-line API-key option further makes it possible for a maliciously supplied command to combine a user credential wit ...[truncated 1961 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the runtime base-URL override when custom deployments are not required, and always use the fixed
DEFAULT_BASE_URL. - If custom endpoints are a legitimate requirement, parse the URL and require:
- The
httpsscheme. - An explicit allowlist of trusted hostnames.
- The expected API path.
- No embedded username or password.
- The
- Never attach the bearer credential until the final request destination has passed validation.
- Require an explicit security confirmation before sending credentials to any non-default endpoint. Clearly display the destination hostname without displaying the API key.
- Reject plaintext HTTP endpoints to prevent credential interception in transit.
- Prefer environment variables or a permission-restricted credential file over
--api-key, and consider removing the command-line secret option. - Add tests confirming that attacker-controlled hosts, plaintext URLs, malformed URLs, and unapproved ports are rejected.
- Document credential revocation and rotation procedures in case a key has already been sent to an untrusted endpoint.
- Remove the runtime base-URL override when custom deployments are not required, and always use the fixed
