T09 · Insecure Skill Coding Practices
- Location
scripts/temu_product_query.py:36- Finding
API Key Disclosure Through an Unrestricted Gateway Override
- Content
View full analysis
str: """Gateway base address: environment variable first, production address by default.""" return (os.environ.get("LINKFOX_TOOL_GATEWAY") or "https://tool-gateway.linkfox.com").rstrip("/") def get_api_url(): sys.path.insert( 0, os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", "_shared", ), ) 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: print("API Key is not configured", file=sys.stderr) 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", ""), "MODE_ID": os.environ.get("MODE_ID", ""), "APP_NAME": os.environ.get("APP_NAME", ""), } req = Request( api_url, data=data, headers=headers, method="POST", ) ``` ### Technical Analysis The product-query destination is taken directly from `LINKFOX_TOOL_GATEWAY`. The script does not require HTTPS, validate the hostname, restrict ports, or compare the destination against a trusted-host allowlist. The API key is subsequently placed in the `Authorization` header and sent to that destination. Product-query parameters and host metadata—including `SESSION_ID`, `MODE_ID`, and `APP_NAME`—are transmitted in the same request. This network access is necessa ...[truncated 1396 chars]- Remediation
View remediation
