T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/neuron_skill.py:127
- Finding
- Unauthenticated UDP discovery permits peer-list poisoning and unsafe task distribution<![CDATA[ ## Vulnerability Details **File Location**: `scripts/neuron_skill.py:127-149, 217-228` **Vulnerability Type**: Unauthenticated network discovery and peer trust **Risk Level**: High ### Vulnerable Code ```python while True: try: data, addr = sock.recvfrom(1024) msg = json.loads(data.decode()) if msg.get("type") == "announce": node_id = msg["node_id"] ip = msg["ip"] if node_id == self.node_id: continue with self.lock: self.nodes[node_id] = { "ip": ip, "last_seen": time.time() } except socket.timeout: continue except Exception as e: print(f"监听错误: {e}") ``` ```python if hasattr(context, 'rpc_call'): result = context.rpc_call( node_id=node["id"], skill="neuron", params={"question": question, "distribute": False, "task_id": task_id}, timeout=self.config["task_timeout"] ) ``` ### Technical Analysis The discovery listener accepts every correctly formatted UDP announcement without authenticating the sender, validating message integrity, checking an allowlist, preventing replay, or confirming that the advertised node identity belongs to the source. The packet's source address in `addr` is not validated against the advertised address. Accepted node IDs are subsequently passed to `context.rpc_call`. Consequently, a reachable attacker that also controls or can register the announced RPC node identity may cause user questions to be sent to an unauthorized node. Even where the RPC framework independently rejects the identity, forged announcements can still poison the local node list, trigger repeated failed RPC calls, and consume task-processing resources. The code also places no effective bound on discovered peers. Although `max_parallel_tasks` exists in configuration, it is not enforced when creating one thread per discovered node. ...[truncated 1436 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Authenticate discovery announcements using signatures or message authentication codes tied to provisioned node credentials. - Use mutual authentication and encrypted transport for all distributed task RPC calls. - Maintain an explicit allowlist of trusted peer identities and require administrative or user approval before adding new peers. - Validate announcement source addresses and do not trust an IP address supplied inside the datagram. - Add nonces, bounded timestamps, and replay protection. - Impose strict limits on the number of discovered nodes and enforce `max_parallel_tasks` through a bounded executor. - Require explicit user consent before distributing questions, particularly when prompts may contain sensitive information. - Reject or quarantine peers that repeatedly fail authentication or RPC connectivity checks. ]]>
