T09 · Insecure Skill Coding Practices
- Location
scripts/_spapi_orders_common.py:18- Finding
Configurable Gateway Can Redirect API Keys and Amazon Access Tokens to an Untrusted Host
- Content
View full analysis
str: """ 获取配置在环境变量的API Key。 如果获取不到,按 SKILL.md 的 **## 解决认证和积分问题** 处理。 """ key = os.environ.get("LINKFOX_AGENT_API_KEY") or os.environ.get("LINKFOXAGENT_API_KEY") if not key: print( "API Key 未配置", file=sys.stderr, ) sys.exit(1) return key 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", }, method="POST", ) try: with urlopen(req, timeout=150) as response: return json.loads(response.read().decode("utf-8")) ``` The same endpoint-selection and request pattern is replicated across other `_spapi_*_common.py` modules and several standalone API scripts. ### Technical Analysis The gateway base URL is accepted directly from environment variables without validating: - The URL scheme. - The destination hostname. - The destination port. - Embedded URL credentials. - Redirect behavior. - Whether the destination is an approved LinkFox service. Every request adds the LinkFox API key to the `Authorization` header. Developer-proxy requests also include the Amazon access token in the JSON request body u ...[truncated 1552 chars]- Remediation
View remediation
