T09 · Insecure Skill Coding Practices
- Location
- scripts/echotik_list_new_product_rank.py:35
- Finding
- Configurable Network Endpoints Can Exfiltrate API Keys, Access Tokens, and Session Metadata<![CDATA[ ## Vulnerability Details **File Location**: `scripts/echotik_list_new_product_rank.py:35-80`; `scripts/onboarding.py:69-89, 209-230, 402-466` **Vulnerability Type**: Credential exfiltration through unrestricted endpoint overrides **Risk Level**: High ### Technical Analysis The primary API endpoint can be replaced through `LINKFOX_TOOL_GATEWAY`. The script then sends the LinkFox API key and session-related identifiers to that endpoint without validating the scheme or destination host: ```python def get_api_base() -> str: """Gateway base address: environment override, then production.""" return (os.environ.get("LINKFOX_TOOL_GATEWAY") or "https://tool-gateway.linkfox.com").rstrip("/") def call_api(params): 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", ""), "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") with urlopen(req, timeout=150) as response: return json.loads(response.read().decode("utf-8")) ``` The onboarding script applies the same pattern to three endpoints: ```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", ) ``` These endpoint values are used in requests carrying phone numbers, SMS verification codes, API keys, access tokens, refresh ...[truncated 2499 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove production endpoint overrides unless they are required for an explicitly enabled development mode. 2. Enforce `https` and an exact hostname allowlist before attaching credentials: - `tool-gateway.linkfox.com` - `api.linkfox.com` - `agent-api.linkfox.com` 3. Reject URLs containing user information, unexpected ports, fragments, or nonempty paths outside the expected base path. 4. Never attach an authorization header until the final destination has been validated. 5. Minimize request headers by removing `MESSAGE_ID`, `MODE_ID`, `APP_NAME`, and `SESSION_ID` unless each field has a documented functional requirement and user-facing privacy disclosure. 6. If custom enterprise gateways must be supported, require an explicit command-line opt-in and separate credentials scoped only to that gateway. 7. Add automated tests proving that credentials are not sent after cross-origin redirects and that plaintext HTTP endpoints are rejected. ]]>
