T09 · Insecure Skill Coding Practices
- Location
scripts/xunbee_inbox.py:21- Finding
API Key Disclosure Through an Unrestricted HTTPS Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/xunbee_inbox.py, lines 21–30, 54–65, and 138–142
Vulnerability Type: Credential disclosure through insufficient destination validation
Risk Level: HighVulnerable Code
python def _base_url(value: str) -> str: parsed = urlsplit(value.strip()) if parsed.scheme != "https" or not parsed.netloc: raise InboxClientError("XUNBEE base URL must be an absolute HTTPS URL") if parsed.username or parsed.password or parsed.query or parsed.fragment: raise InboxClientError( "XUNBEE base URL must not contain credentials, query, or fragment" ) return urlunsplit((parsed.scheme, parsed.netloc, parsed.path.rstrip("/"), "", ""))python url = f"{_base_url(args.base_url)}{MESSAGES_PATH}?{urlencode(query)}" request = Request( url, headers={ "Accept": "application/json", "Authorization": f"Bearer {_api_key()}", }, method="GET", ) try: with urlopen(request, timeout=args.timeout) as response: payload = json.load(response)python parser.add_argument( "--base-url", default=os.environ.get("XUNBEE_BASE_URL", DEFAULT_BASE_URL), )Technical Analysis
The client reads the sensitive
XUNBEE_API_KEYenvironment variable and sends it in an HTTPAuthorizationheader. Sending this credential to the official XUNBEE API is necessary for the declared inbox-reading functionality.However,
_base_url()validates only that the supplied destination uses HTTPS and has a network location. It does not restrict the destination to the officialcc.akuwan.cnorigin or another pre-approved set of XUNBEE instances. Any syntactically valid HTTPS host is accepted, and the API key is then attached to the request unconditionally.The destination can be selected through either the
--base-urlcommand-line option or theXUNBEE_BASE_URLenvi ...[truncated 2269 chars]- Remediation
View remediation
Remediation Suggestions
-
Bind the API key to the official origin by default. Permit credential-bearing requests only to the exact normalized origin
https://cc.akuwan.cn. -
Use an explicit allowlist for private deployments. If custom XUNBEE instances are required, configure approved origins through trusted administrator-controlled configuration rather than ordinary agent-generated command arguments.
-
Separate credentials by origin. Do not send
XUNBEE_API_KEYto a custom origin. Require a separately configured credential associated with that exact origin. -
Disable or tightly control redirects. Reject cross-origin redirects for authenticated requests. If redirects are supported, compare the scheme, hostname, and effective port of every redirect target with the original approved origin and strip
Authorizationwhenever the origin changes. -
Validate the final response origin. Ensure the effective response URL remains on the approved origin before parsing or trusting returned data.
-
Restrict URL components further. Normalize hostnames and ports, reject unexpected ports, and avoid allowing arbitrary base paths unless private-instance compatibility explicitly requires them.
-
Reduce agent influence over security configuration. The Skill instructions should prohibit deriving or changing
--base-urlfrom user-provided message content, remote pages, or untrusted prompts. Prefer omitting the command-line option in normal agent invocation. -
Add security tests. Verify that attacker-controlled hosts, alternate ports, user-info URLs, malformed hosts, and cross-origin redirects cannot receive the Bearer token.
-
