T09 · Insecure Skill Coding Practices
- Location
markets_skill.py:32- Finding
Bearer Credentials Can Be Transmitted over Unencrypted or Untrusted Endpoints
- Content
View full analysis
Dict[str, str]: """获取请求头""" headers = {"Content-Type": "application/json"} if self.api_key: headers["Authorization"] = f"Bearer {self.api_key}" return headers async def connect(self) -> bool: """ 连接到 ClawMarkets API Returns: bool: 连接是否成功 """ try: self.session = aiohttp.ClientSession() # 测试连接 async with self.session.get( f"{self.api_base_url}/health", headers=await self._get_headers(), timeout=aiohttp.ClientTimeout(total=10) ) as response: ``` The same authorization header is also attached to market creation, order submission, position retrieval, trade-history retrieval, and market-information requests. ### Technical Analysis The API base URL is accepted without validating its scheme or destination. Although the default points to loopback, callers can provide any HTTP or HTTPS URL. When an API key is configured, `_get_headers()` adds it as a bearer token to every request, including the initial health check. If a caller configures a non-loopback plaintext HTTP endpoint, the bearer credential is transmitted without transport encryptio ...[truncated 1902 chars]- Remediation
View remediation
