T09 · Insecure Skill Coding Practices
- Location
scripts/call_api.py:51- Finding
Configurable API Endpoint Can Exfiltrate Credentials and User Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/config.py:9-14;scripts/call_api.py:51-67
Vulnerability Type: Credential disclosure through an unvalidated configurable endpoint
Risk Level: HighVulnerable Code
python # scripts/config.py:9-14 model_config = SettingsConfigDict( env_prefix="XBY_GAOKAO_", env_file=".env", env_file_encoding="utf-8", extra="ignore", )python # scripts/config.py:17 base_url: str = "https://mcp.xiaobenyang.com"python # scripts/call_api.py:51-67 url = f"{settings.base_url}/api" mcp_id = mcp_id or settings.mcp_id api_key = get_api_key() if not api_key: raise UpstreamError("API密钥未设置,请先调用 set_api_key()") headers = { "XBY-APIKEY": api_key, "func": tool_name, "mcpid": mcp_id, "Content-Type": "application/json", } # data = {k: str(v) if v is not None else "" for k, v in params.items()} t0 = time.time() try: resp = self._session.post( url=url, headers=headers, data=json.dumps(params), timeout=settings.timeout_seconds, )Technical Analysis
The
Settingsclass permits configuration values to be supplied through environment variables with theXBY_GAOKAO_prefix. Consequently,base_urlcan be overridden usingXBY_GAOKAO_BASE_URL.The HTTP client constructs the API URL directly from this configurable value and unconditionally adds the
XBY-APIKEYcredential to the request. It does not verify that the scheme is HTTPS or that the destination hostname is the expectedmcp.xiaobenyang.comservice.An attacker who can influence the process environment or
.envconfiguration can therefore redirect authenticated requests to an attacker-controlled server. The credential and all tool parameters will then be disclosed to that server.Attack Path
- The attacker gains the ability to influence the Skill's runtime environment or configuration file.
- The attacker sets
XBY_GAOKAO_BASE_URLto an attacker-controll ...[truncated 1028 chars]
- Remediation
View remediation
Remediation Suggestions
- Keep the authenticated API origin fixed in code when runtime customization is not required.
- If endpoint configuration is required, parse the URL and enforce:
- The
httpsscheme. - An exact allowlisted hostname.
- An expected port.
- Rejection of embedded credentials, fragments, and unexpected paths.
- The
- Validate the final request URL immediately before attaching the API key.
- Do not forward credentials across redirects. Disable redirects or verify every redirect destination against the same allowlist.
- Separate development endpoint overrides from production builds and never send production credentials to development endpoints.
- Add automated tests confirming that HTTP URLs, unapproved hosts, subdomain lookalikes, and redirect-based destination changes are rejected.
