T09 · Insecure Skill Coding Practices
- Location
- scripts/chuhaijiang_seller_search.py:37
- Finding
- Credentials and personal authentication data can be forwarded to unrestricted configurable origins<![CDATA[ ## Vulnerability Details **File Location**: - `scripts/chuhaijiang_seller_search.py:37-39, 62-80` - `scripts/chuhaijiang_seller_detail.py:37-39, 62-80` - `scripts/chuhaijiang_seller_related_creators.py:37-39, 62-80` - `scripts/chuhaijiang_seller_related_products.py:37-39, 62-80` - `scripts/chuhaijiang_seller_related_videos.py:37-39, 62-80` - `scripts/chuhaijiang_seller_rank_most_promoted.py:37-39, 62-80` - `scripts/chuhaijiang_seller_rank_top_selling.py:37-39, 62-80` - `scripts/onboarding.py:71-85, 208-229, 376-418, 451-459` **Vulnerability Type**: Unrestricted credential forwarding to environment-controlled network origins **Risk Level**: High ### Vulnerable Code Representative code shared by the seven seller API scripts: ```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")) ``` Relevant onboarding origin configuration and credential-header construction: ```python def _agent_base() -> str: return _env_base( "LINKFOX_AGENT_API_URL", ...[truncated 5244 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Use hard-coded HTTPS production origins for normal operation: - `https://tool-gateway.linkfox.com` - `https://api.linkfox.com` - `https://agent-api.linkfox.com` 2. If endpoint overrides are required for development, require an explicit development-mode flag that is disabled by default. 3. Parse each override with `urllib.parse.urlsplit` and enforce: - `scheme == "https"` - An exact allowlisted hostname - No username or password component - No query string or fragment - No IP-literal or localhost destination - No non-approved port 4. Apply separate allowlists for gateway, login, and agent-user services. Do not allow one environment variable to redirect credentials intended for another trust domain. 5. Reject invalid configuration before retrieving credentials or constructing authorization headers. 6. Ensure authorization headers are not forwarded to a different origin during redirects. Prefer rejecting redirects for authenticated requests or explicitly validating every redirect target before following it. 7. Keep development credentials isolated from production credentials. Tests using custom endpoints should use non-production tokens with minimal permissions and short expiration periods. 8. Add automated tests proving that HTTP URLs, unapproved hosts, embedded credentials, IP literals, and unauthorized ports are rejected. ]]>
