T09 · Insecure Skill Coding Practices
- Location
scripts/config.py:12- Finding
API endpoint override permits credential transmission to an attacker-controlled server
- Content
View full analysis
Vulnerability Details
File Location:
scripts/config.py:12-20;scripts/call_api.py:50-69
Vulnerability Type: Configurable endpoint enabling credential disclosure
Risk Level: HighVulnerable Code
python model_config = SettingsConfigDict( env_prefix="XBY_GAOKAO_", env_file=".env", env_file_encoding="utf-8", extra="ignore", ) # API配置 base_url: str = "https://mcp.xiaobenyang.com" mcp_id: str = "1820705335657482" api_key: str = ""python 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 Pydantic settings model uses the
XBY_GAOKAO_environment-variable prefix. Consequently,XBY_GAOKAO_BASE_URLcan override the declaredbase_url. The resulting URL is used without validating its scheme or hostname.call_tool()then attaches the user's API key to theXBY-APIKEYrequest header and sends the submitted domain data to that URL. There is no destination allowlist and no explicit requirement that the resolved endpoint use HTTPS.This issue is exploitable when an attacker can influence the process environment or the settings sources used when the Skill starts. It does not independently grant such access, but it turns configuration influence into disclosure of a subsequently supplied credential.
Attack Path
- An attacker capable of controlling the Skill's environment sets
XBY_GAOKAO_BASE_URLto an attacker ...[truncated 1042 chars]
- An attacker capable of controlling the Skill's environment sets
- Remediation
View remediation
Remediation Suggestions
- Make the production API endpoint a non-overridable constant if endpoint customization is unnecessary.
- Before transmitting credentials, parse the URL and require:
- The
httpsscheme. - The exact approved hostname
mcp.xiaobenyang.com. - An expected port and path.
- No embedded user information.
- The
- Reject redirects to unapproved hosts, because an approved initial endpoint could otherwise redirect a credential-bearing request.
- If alternate endpoints are required for testing, separate test and production credentials and require an explicit, trusted configuration mode.
- Add automated tests verifying that HTTP URLs, unexpected hosts, subdomain lookalikes, and redirect-based destination changes are rejected.
- Avoid including credential-bearing headers in requests until destination validation has completed.
