T09 · Insecure Skill Coding Practices
- Location
scripts/config.py:11- Finding
Configurable API Endpoint Enables Credential and Image-Data Redirection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/config.py:11-22; data transmission occurs atscripts/call_api.py:50-68
Vulnerability Type: Unvalidated configurable endpoint receiving sensitive credentials and user data
Risk Level: MediumVulnerable Code
scripts/config.py:11-22:python model_config = SettingsConfigDict( env_prefix="XBY_GAOKAO_", env_file=".env", env_file_encoding="utf-8", extra="ignore", ) # API configuration base_url: str = "https://mcp.xiaobenyang.com" mcp_id: str = "1820705335657482" api_key: str = ""scripts/call_api.py:50-68: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", } t0 = time.time() try: resp = self._session.post( url=url, headers=headers, data=json.dumps(params), timeout=settings.timeout_seconds, )Technical Analysis
Pydantic settings use the
XBY_GAOKAO_environment-variable prefix, allowingbase_urlto be overridden throughXBY_GAOKAO_BASE_URL. The HTTP client constructs its destination directly from that configurable value and attaches the API key in theXBY-APIKEYheader.No validation restricts the destination to HTTPS or to the expected
mcp.xiaobenyang.comhostname. Consequently, anyone able to influence the process environment or configuration can redirect requests to an arbitrary server. The request body contains either an externally supplied image URL or Base64-encoded image data.The client also relies on the default redirect behavior of
requestswithout explicitly validating redirect destinations. This creates an additional opportunity for sensitive request handling to devia ...[truncated 1219 chars]- Remediation
View remediation
Remediation Suggestions
- Make the production API endpoint immutable when runtime endpoint customization is unnecessary.
- If configurability is required, parse the URL and require:
- The
httpsscheme. - An exact approved hostname, such as
mcp.xiaobenyang.com. - An approved port and path.
- No embedded credentials.
- The
- Reject alternate hosts, IP-literal destinations, and malformed URLs.
- Disable automatic redirects for authenticated requests or validate every redirect destination against the same allowlist before following it.
- Keep API credentials scoped to the minimum required permissions and support prompt rotation after suspected disclosure.
- Add tests proving that environment variables cannot redirect credentials to unapproved destinations.
