T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/chuhaijiang_product_detail.py:29
- Finding
- Credential Exfiltration Through Unvalidated Configurable API Endpoints<![CDATA[ ## Vulnerability Details **File Location**: `scripts/chuhaijiang_product_detail.py:29-31, 156-174`; equivalent behavior exists in all `scripts/chuhaijiang_product_*.py` clients and `scripts/upload_image.py`. Related configurable authentication endpoints exist in `scripts/onboarding.py:77-85, 229-247`. **Vulnerability Type**: Credential disclosure through untrusted endpoint configuration **Risk Level**: High ### Vulnerable Code ```python def get_api_base() -> str: return (os.environ.get("LINKFOX_TOOL_GATEWAY") or "https://tool-gateway.linkfox.com").rstrip("/") ``` ```python def call_api(params): global _LAST_CALL_WAS_HTTP_ERROR _LAST_CALL_WAS_HTTP_ERROR = False api_url = get_api_url() api_key = get_api_key() data = json.dumps(params).encode("utf-8") headers = { "Authorization": api_key, "Content-Type": "application/json", "User-Agent": "LinkFox-Skill/2.0", "SESSION_ID": (os.environ.get("SESSION_ID") or "").strip(), "MESSAGE_ID": os.environ.get("MESSAGE_ID", ""), "MODE_ID": os.environ.get("MODE_ID", ""), "APP_NAME": os.environ.get("APP_NAME", ""), } req = Request( api_url, data=data, headers=headers, method="POST", ) try: with urlopen(req, timeout=150) as response: raw = response.read().decode("utf-8") ``` Onboarding also permits independent overrides: ```python def _agent_base() -> str: return _env_base( "LINKFOX_AGENT_API_URL", "https://tool-gateway.linkfox.com", "LINKFOX_TOOL_GATEWAY", ) def _login_base() -> str: return _env_base("LINKFOX_LOGIN_API_URL", "https://api.linkfox.com") def _agent_user_base() -> str: return _env_base( "LINKFOX_AGENT_USER_API_URL", "https://agent-api.linkfox.com", ) ``` ### Technical Analysis The API destination is obtained directly from environment variables without validating its scheme or host ...[truncated 1834 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Use fixed production origins for credential-bearing requests. 2. If endpoint overrides are required for development, enforce an explicit allowlist of trusted hostnames. 3. Require HTTPS and reject HTTP, user-information components, unusual ports, loopback addresses, link-local addresses, and private-network destinations. 4. Resolve and validate DNS results before connecting, with safeguards against DNS rebinding. 5. Disable redirects for requests containing credentials, or permit redirects only when the scheme and validated hostname remain unchanged. 6. Maintain separate development credentials for test endpoints. 7. Add automated tests confirming that credentials cannot be sent to non-allowlisted destinations. 8. Centralize endpoint and credential handling instead of duplicating the vulnerable client implementation across scripts. ]]>
