T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- server.py:145
- Finding
- Unauthenticated Network Exposure of Agent Session Conversations<![CDATA[ ## Vulnerability Details **File Location**: `server.py`, lines 17-26, 145-198, and 234-240 **Vulnerability Type**: Missing authentication and excessive data exposure **Risk Level**: High ### Vulnerable Code ```python def get_available_agents(): """获取所有可用的 agent""" agents_dir = SESSION_DIR if not agents_dir.exists(): return [] agents = [] for item in agents_dir.iterdir(): if item.is_dir() and (item / "sessions").exists(): agents.append(item.name) return sorted(agents) ``` ```python if path == '/api/agents': # 返回可用 agent 列表 agents = get_available_agents() self.send_response(200) self.send_header('Content-type', 'application/json') self.send_header('Access-Control-Allow-Origin', '*') self.end_headers() self.wfile.write(json.dumps({'agents': agents}).encode()) elif path == '/api/conversations': # 返回对话 agent1 = params.get('agent1', [''])[0] agent2 = params.get('agent2', [''])[0] if not agent1 or not agent2: self.send_response(400) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(json.dumps({'error': 'Missing agent1 or agent2'}).encode()) return convos = get_conversations(agent1, agent2) # 合并消息 all_msgs = [] msgs1 = convos.get('agent-1', []) msgs2 = convos.get('agent-2', []) max_len = max(len(msgs1), len(msgs2)) for i in range(max_len): if i < len(msgs2): all_msgs.append({ 'from': 'agent-2', 'content': msgs2[i]['content'], 'time': msgs2[i]['time'] }) if i < len(msgs1): all_msgs.append({ 'from': 'agent-1', 'content': msgs1[i]['content'], 'time': msgs1[i]['time'] }) self.send_response(200) self.send_header('Content-type', 'application/json') self.send_header('Access-Control-Allow ...[truncated 2886 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Bind the viewer exclusively to the loopback interface: ```python server = HTTPServer(('127.0.0.1', PORT), Handler) ``` 2. Require authenticated requests using a securely generated session or bearer token. Compare authentication values using a constant-time comparison where applicable. 3. Enforce server-side authorization. Restrict the viewer to an explicit allowlist containing only `job-seeker` and `recruiter`. 4. Do not use `Access-Control-Allow-Origin: *`. If cross-origin access is necessary, permit only an explicitly configured trusted origin and reject untrusted `Origin` values. 5. Return only the fields required by the viewer and redact secrets or sensitive metadata from session content. 6. Add rate limiting and security logging for agent enumeration and conversation access. 7. Document that session conversations are sensitive local data and that the viewer must not be exposed through a public interface or untrusted reverse proxy. ]]>
