T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/chuhaijiang_live_search.py:39
- Finding
- Credential Disclosure Through Unrestricted API Endpoint Overrides<![CDATA[ ## Vulnerability Details **File Location**: - `scripts/chuhaijiang_live_search.py:39-80` - `scripts/chuhaijiang_live_detail.py:39-80` - `scripts/chuhaijiang_live_related_products.py:39-80` - `scripts/onboarding.py:78-85, 195-221, 399-418, 451-456` **Vulnerability Type**: Credentials sent to environment-controlled network destinations **Risk Level**: High ### Vulnerable Code The three livestream API scripts contain equivalent implementations: ```python def get_api_base() -> str: """Gateway base address: LINKFOX_TOOL_GATEWAY takes precedence.""" return (os.environ.get("LINKFOX_TOOL_GATEWAY") or "https://tool-gateway.linkfox.com").rstrip("/") def get_api_url(): return get_api_base() + API_PATH 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: return json.loads(response.read().decode("utf-8")) ``` The onboarding script similarly permits overrides for services receiving login credentials and access tokens: ```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("LIN ...[truncated 2658 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Allow credential-bearing production requests only to an explicit hostname allowlist, such as the documented LinkFox service domains. 2. Require the resolved URL scheme to be `https`. 3. Reject URLs containing user information, unexpected ports, fragments, or deceptive hostname suffixes. 4. Resolve and validate each final request URL after joining the base URL and path. 5. Disable endpoint overrides by default. If overrides are required for development, require an explicit development-mode flag and test-only credentials. 6. Never attach production authorization headers when the destination is not an approved origin. 7. Minimize telemetry headers. Send `SESSION_ID`, `MESSAGE_ID`, `MODE_ID`, and `APP_NAME` only where they are operationally required. 8. Add tests proving that HTTP destinations, subdomain-confusion values, and unapproved domains are rejected before any network request occurs. ]]>
