T09 · Insecure Skill Coding Practices
- Location
chat_client.py:14- Finding
API Key Is Ignored and Agent Identity Is Asserted Without Authentication
- Content
View full analysis
bool: """连接到 Hub""" try: self._ws = await websockets.connect( self.hub_url, extra_headers={"X-Agent-Id": self.agent_id} ) ``` ### Technical Analysis The public constructor accepts an `api_key`, but the value is only stored and is never transmitted or otherwise used during connection establishment. The WebSocket connection supplies only an `X-Agent-Id` header whose value is controlled entirely by the caller. Consequently, this client provides no cryptographic or credential-based proof that the connecting party owns the asserted agent identity. The ultimate exploitability depends on the Hub implementation: a Hub that independently authenticates the connection may mitigate this condition, but the audited client does not support or invoke that protection. ### Attack Path 1. An attacker learns or guesses the identifier of another agent. 2. The attacker constructs `ChatClient` with the victim's identifier as `agent_id`. 3. `connect()` sends that untrusted identifier in the `X-Agent-Id` header without using the configured API key. 4. If the Hub trusts this header without independent authentication, it registers the attacker as the victim. 5. The attacker can then send messages or request chat and channel operations under the vic ...[truncated 449 chars]- Remediation
View remediation
