T09 · Insecure Skill Coding Practices
- Location
scripts/chuhaijiang_ad_search.py:47- Finding
Configurable Network Endpoints Can Receive Credentials and Session Metadata
- Content
View full analysis
Vulnerability Details
File Location:
scripts/chuhaijiang_ad_search.py:47-52, 68-90; equivalent behavior exists inscripts/chuhaijiang_ad_detail.py,scripts/chuhaijiang_ad_related_products.py,scripts/chuhaijiang_creative_search.py, andscripts/chuhaijiang_creative_detail.py. Sensitive onboarding endpoints are configurable atscripts/onboarding.py:76-85, 193-195, 229-247, 399-418, 451-458.
Vulnerability Type: Unvalidated destination for authenticated network requests
Risk Level: HighVulnerable 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
View remediation
Remediation Suggestions
- Enforce HTTPS for every endpoint carrying credentials.
- Allow only explicit production hostnames such as
tool-gateway.linkfox.com,api.linkfox.com, andagent-api.linkfox.com. - Reject URLs containing user information, fragments, unexpected ports, ambiguous host encodings, or non-empty paths where only a base origin is expected.
- Resolve and compare normalized hostnames rather than using suffix or substring checks.
- Disable redirects for authenticated requests, or validate every redirect destination against the same allowlist before following it.
- If custom enterprise gateways are required, place them behind an explicit opt-in configuration and require informed user approval before forwarding credentials.
- Use separate, narrowly scoped credentials for search, onboarding, and billing operations.
- Avoid forwarding
SESSION_ID,MESSAGE_ID,MODE_ID, andAPP_NAMEunless each field is operationally necessary. - Add automated tests confirming that HTTP URLs, attacker domains, malformed URLs, and cross-host redirects are rejected before any sensitive request is sent.
