T09 · Insecure Skill Coding Practices
- Location
scripts/_shopee_fbs_common.py:18- Finding
Credential-Bearing Requests Can Be Redirected to Untrusted Endpoints
- Content
View full analysis
Vulnerability Details
File Location:
scripts/_shopee_fbs_common.py:18-20, 71-88;scripts/onboarding.py:68-85, 190-222, 225-246, 365-421, 454-461
Vulnerability Type: Unvalidated credential endpoint configuration
Risk Level: HighVulnerable Code
scripts/_shopee_fbs_common.py:18-20, 71-88:python API_BASE_URL = os.environ.get("LINKFOX_TOOL_GATEWAY") or os.environ.get("SHOPEE_API_BASE_URL") or "https://tool-gateway.linkfox.com" STORE_TOKENS_ENDPOINT = f"{API_BASE_URL.rstrip('/')}/shopee/storeTokens" DEVELOPER_PROXY_ENDPOINT = f"{API_BASE_URL.rstrip('/')}/shopee/developerProxy" def call_api(endpoint: str, params: dict) -> dict: api_key = get_api_key() data = json.dumps(params).encode("utf-8") req = Request( endpoint, data=data, headers={ "Authorization": api_key, "Content-Type": "application/json", "User-Agent": "LinkFox-Skill/1.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", ""), }, method="POST", ) try: with urlopen(req, timeout=150) as response: return json.loads(response.read().decode("utf-8"))scripts/onboarding.py:68-85, 190-222:python def _env_base(name: str, default: str, *fallbacks: str) -> str: for n in (name, *fallbacks): v = os.environ.get(n) if v: return v.rstrip("/") return default.rstrip("/") 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 ...[truncated 3899 chars]- Remediation
View remediation
Remediation Suggestions
- Require
httpsfor every credential-bearing endpoint. - Allowlist exact production hostnames such as
tool-gateway.linkfox.com,api.linkfox.com, andagent-api.linkfox.com. - Reject URLs containing embedded credentials, unexpected ports, fragments, or nonempty user-information components.
- Resolve and validate the final destination after redirects, or disable redirects for requests carrying credentials.
- Remove production endpoint overrides unless they are operationally necessary.
- If custom development endpoints are required, require an explicit development-mode flag and separate test credentials. Do not forward production credentials by default.
- Avoid sending
SESSION_ID,MESSAGE_ID,MODE_ID, andAPP_NAMEunless each field is required by the server. - Add tests proving that HTTP URLs, unapproved hosts, malformed URLs, and redirects to unapproved hosts are rejected before any sensitive request is sent.
- Require
