T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:91- Finding
Bearer Credential Can Be Sent to an Unrestricted Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py:91-99, 130-143
Vulnerability Type: Unrestricted credential destination and missing transport validation
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", } 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 a command-line argument, the
AI_HIVE_BASE_URLenvironment variable, or the local configuration file. The value is accepted without validating its scheme, hostname, port, or relationship to the expected AI-HIVE service.The HTTP client subsequently adds the AI-HIVE bearer credential to every request made through that base URL. Consequently, an attacker who can influence the process environment, command invocation, or configuration file can redirect authenticated requests to an attacker-controlled server. The implementation also permits an
http://endpoint, which can expose the credential to network interception.Custom endpoint support is not necessary for the Skill's declared single-service integration and therefore exceeds the minimum privileges requir ...[truncated 1176 chars]
- Remediation
View remediation
Remediation Suggestions
- Restrict authenticated requests to the expected HTTPS origin, such as
https://ai-hive.iclip.cn/api. - Parse the configured URL with
urllib.parse.urlparseand reject unsupported schemes, embedded credentials, unexpected hostnames, and unexpected ports. - Reject plaintext HTTP for any request carrying an API credential.
- Construct the
Authorizationheader only after the destination has passed validation. - If custom endpoints are needed for testing, require an explicit development-only switch and separate credentials that cannot access production resources.
- Warn or terminate when the environment variable and configuration file attempt to override the production origin.
- Add automated tests verifying that malicious hosts, redirects, plaintext URLs, user-information components, and malformed URLs cannot receive the bearer token.
- Consider disabling automatic redirects or validating every redirect destination before forwarding authorization headers.
- Restrict authenticated requests to the expected HTTPS origin, such as
