T09 · Insecure Skill Coding Practices
- Location
scripts/videogen.py:99- Finding
Unrestricted API Base URL Can Expose Bearer Credentials and Sensitive Request Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/videogen.py, lines 99-141
Vulnerability Type: Unrestricted credential forwarding to a 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 )The corresponding command-line option is registered at lines 608-609:
python parser.add_argument("--base-url", help=f"API Base URL (default {DEFAULT_BASE_URL})")Technical Analysis
The API endpoint can be supplied through
--base-url, theAI_HIVE_BASE_URLenvironment variable, or the local configuration file. The value is accepted without validating its scheme, hostname, port, user-information component, or destination.AiHiveClientsubsequently attaches the API key as a bearer token to every request made to that endpoint. Consequently, any selected server receives the API credential. API requests may additionally contain prompts, filenames, media metadata, model parameters, pricing information, and task identifiers.Plain HTTP endpoints are also accepted. In that case, credentials and request content ma ...[truncated 1490 chars]
- Remediation
View remediation
Remediation Suggestions
- Allow only the documented production origin by default, such as
https://ai-hive.iclip.cn/api. - Parse endpoints with
urllib.parse.urlsplit()and require:- The
httpsscheme. - An explicitly approved hostname.
- No embedded username or password.
- No fragment.
- Only expected ports.
- The
- Do not attach the production API key to an endpoint outside the approved origin.
- If custom endpoints are a necessary development feature, place them behind an explicit development-only option and require separate credentials.
- Reject plaintext HTTP even for configuration-file and environment-variable values.
- Warn clearly before transmitting prompts or media metadata to a non-default endpoint.
- Consider restricting or ignoring
AI_HIVE_BASE_URLin production automation where environment variables may be injected by less-trusted components.
- Allow only the documented production origin by default, such as
