T09 · Insecure Skill Coding Practices
- Location
scripts/config.py:14- Finding
Configurable API Endpoint Enables Credential and Financial Data Exfiltration
- Content
View full analysis
Vulnerability Details
File Location:
scripts/config.py:14-18andscripts/call_api.py:53-66
Vulnerability Type: Unvalidated configurable network destination
Risk Level: MediumVulnerable Code
scripts/config.py:14-18:python model_config = SettingsConfigDict( env_prefix="XBY_GAOKAO_", env_file=".env", env_file_encoding="utf-8", extra="ignore", )scripts/config.py:21-23:python base_url: str = "https://mcp.xiaobenyang.com" mcp_id: str = "1820705335657482" api_key: str = ""scripts/call_api.py:53-66: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", }scripts/call_api.py:72-77:python resp = self._session.post( url=url, headers=headers, data=json.dumps(params), timeout=settings.timeout_seconds, )Technical Analysis
The
Settingsmodel permits fields to be overridden through environment variables prefixed withXBY_GAOKAO_or through the.envfile. Consequently,XBY_GAOKAO_BASE_URLcan replace the expected XiaoBenYang endpoint.Before adding the API key to the
XBY-APIKEYrequest header,call_tool()does not validate that the effective URL uses HTTPS or that its hostname is exactly an approved XiaoBenYang domain. All tool parameters are also serialized into the request body. These parameters can include net taxable income, household composition, tax queries, and report contents.An attacker capable of influencing the process environment or the Skill's
.envfile can therefore redirect requests to a server under the attacker's control. The request will disclose both the API credential and user-supplied financial informa ...[truncated 1247 chars]- Remediation
View remediation
Remediation Suggestions
- Make the production API endpoint immutable if runtime customization is unnecessary.
- If endpoint configuration is required, parse it with
urllib.parse.urlsplitand enforce:- The
httpsscheme. - An exact approved hostname, such as
mcp.xiaobenyang.com. - The expected port.
- No embedded user information.
- The
- Maintain an explicit destination allowlist rather than using suffix or substring comparisons.
- Disable automatic cross-origin redirects for authenticated requests, or validate the destination of every redirect before forwarding credentials.
- Separate credential-bearing request configuration from general environment-controlled settings.
- Add tests proving that HTTP URLs, lookalike domains, unapproved ports, and cross-origin redirects are rejected before the API key is attached.
- Document that financial and household parameters are transmitted to the approved third-party API and obtain appropriate user consent.
