T09 · Insecure Skill Coding Practices
- Location
scripts/imagegen.py:105- Finding
Bearer Credential Disclosure Through an Unrestricted API Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/imagegen.py:105-114,scripts/imagegen.py:128-130, andscripts/imagegen.py:557-559
Vulnerability Type: Unrestricted credential forwarding to a configurable network destination
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 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 API base URL can be supplied through the
--base-urlcommand-line argument, theAI_HIVE_BASE_URLenvironment variable, or the persistent configuration file. The value is accepted without enforcing HTTPS or validating that its hostname belongs to the expected AI-HIVE service.The HTTP client attaches the AI-HIVE bearer credential to every request made through this configurable base URL. Consequently, an attacker-controlled base URL receives the production API key in the
Authorizationheader.A custom endpoint can be useful for development, but automatically forwarding an existing production credential to any configured origin exceeds the minimum privilege required for the declared image-generation functionality. The weakness requires control over command arguments, environment variables, configuration, or instructions followed by the ...[truncated 1230 chars]
- Remediation
View remediation
Remediation Suggestions
- Allowlist the production endpoint
https://ai-hive.iclip.cn/apifor normal Skill execution. - Enforce HTTPS and reject plaintext HTTP endpoints.
- Parse URLs with a standard URL parser and compare normalized scheme, hostname, and port rather than using string-prefix checks.
- Do not forward a stored production credential when a custom endpoint is selected.
- If custom endpoints are necessary for development, require a separate credential and an explicit high-friction confirmation that identifies the destination hostname.
- Reject URLs containing embedded user information, unexpected ports, malformed hostnames, or redirect-based origin changes.
- Configure the HTTP client not to preserve the authorization header across cross-origin redirects.
- Document the trust boundary and warn users that changing the endpoint can expose prompts, uploaded media, task data, and credentials.
- Rotate any API key that may already have been used with an untrusted endpoint.
- Allowlist the production endpoint
