T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/chuhaijiang_ad_search.py:47
- Finding
- Configurable Network Endpoints Can Receive Credentials and Session Metadata## Vulnerability Details **File Location**: `scripts/chuhaijiang_ad_search.py:47-52, 68-90`; equivalent behavior exists in `scripts/chuhaijiang_ad_detail.py`, `scripts/chuhaijiang_ad_related_products.py`, `scripts/chuhaijiang_creative_search.py`, and `scripts/chuhaijiang_creative_detail.py`. Sensitive onboarding endpoints are configurable at `scripts/onboarding.py:76-85, 193-195, 229-247, 399-418, 451-458`. **Vulnerability Type**: Unvalidated destination for authenticated network requests **Risk Level**: High ### Vulnerable Code ```python def get_api_base() -> str: """Gateway base URL: LINKFOX_TOOL_GATEWAY takes priority.""" 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")) ``` Onboarding uses the same trust model for more sensitive login and account endpoints: ```python def _agent_base() -> str: return _env_base("LINKFOX_AGENT_API_URL", "https://tool-gateway.linkfox.com", "LINKFOX_TOOL_GATEWAY") def _login_base() -> s ...[truncated 3709 chars]
- Remediation
- ## Remediation Suggestions 1. Enforce HTTPS for every endpoint carrying credentials. 2. Allow only explicit production hostnames such as `tool-gateway.linkfox.com`, `api.linkfox.com`, and `agent-api.linkfox.com`. 3. Reject URLs containing user information, fragments, unexpected ports, ambiguous host encodings, or non-empty paths where only a base origin is expected. 4. Resolve and compare normalized hostnames rather than using suffix or substring checks. 5. Disable redirects for authenticated requests, or validate every redirect destination against the same allowlist before following it. 6. If custom enterprise gateways are required, place them behind an explicit opt-in configuration and require informed user approval before forwarding credentials. 7. Use separate, narrowly scoped credentials for search, onboarding, and billing operations. 8. Avoid forwarding `SESSION_ID`, `MESSAGE_ID`, `MODE_ID`, and `APP_NAME` unless each field is operationally necessary. 9. Add automated tests confirming that HTTP URLs, attacker domains, malformed URLs, and cross-host redirects are rejected before any sensitive request is sent.
