T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/chuhaijiang_video_search.py:38
- Finding
- Credentials and authentication data can be transmitted to unrestricted environment-controlled destinations<![CDATA[ ## Vulnerability Details **File Location**: `scripts/chuhaijiang_video_search.py:38-72`; equivalent behavior exists in `scripts/chuhaijiang_video_detail.py:38-72`, `scripts/chuhaijiang_video_related_products.py:38-72`, and `scripts/chuhaijiang_video_reviews.py:38-72`. Authentication endpoint overrides also exist in `scripts/onboarding.py:68-89`, with sensitive requests at `scripts/onboarding.py:208-221`, `scripts/onboarding.py:399-418`, and `scripts/onboarding.py:451-459`. **Vulnerability Type**: Unrestricted destination override for sensitive network requests **Risk Level**: High ### Vulnerable Code ```python def get_api_base() -> str: """Gateway base URL: 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 get_api_key(): key = os.environ.get("LINKFOX_AGENT_API_KEY") or os.environ.get( "LINKFOXAGENT_API_KEY" ) if not key: sys.exit(1) return key 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") 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") ``` The onboarding script similarly permits replacement of every sensitive service destination: ```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.lin ...[truncated 3211 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require `https` for every configured service URL and reject all other schemes. 2. Enforce an explicit hostname allowlist, such as the documented LinkFox production domains. 3. Reject URLs containing user information, unexpected ports, fragments, or malformed hostnames. 4. Disable automatic redirects or validate every redirect target before forwarding authorization headers. 5. Do not attach credentials until the final destination has passed validation. 6. Separate development endpoint overrides from production behavior and require an explicit, clearly named unsafe-development option. 7. Use separate credentials with narrowly scoped permissions for testing environments. 8. Minimize context headers: transmit `SESSION_ID`, `MESSAGE_ID`, `MODE_ID`, and `APP_NAME` only when required by the selected endpoint. 9. Add automated tests proving that non-HTTPS, off-domain, and redirect-based destinations are rejected. ]]>
