T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- worker_server.py:220
- Finding
- Unauthenticated HTTP Task API Can Invoke Privileged Local Agents<![CDATA[ ## Vulnerability Details **File Location**: `worker_server.py:220-250`, `worker_server.py:314` **Vulnerability Type**: Missing authentication and authorization **Risk Level**: High ### Vulnerable Code ```python def do_POST(self): if self.path == "/tasks": length = int(self.headers.get("Content-Length", 0)) body = self.rfile.read(length).decode("utf-8", errors="replace") try: payload = json.loads(body) if body else {} except json.JSONDecodeError: self.send_json(400, {"error": "invalid json"}) return task_id = payload.get("task_id") or str(uuid.uuid4()) description = payload.get("description", "") title = payload.get("title") or description[:40] or "未命名任务" task_state = { "task_id": task_id, "status": "pending", "title": title, "created_at": now(), "updated_at": now() } with TASK_LOCK: ACTIVE_TASKS[task_id] = task_state thread = threading.Thread( target=self.server.execute_task, args=(task_id, title, description) ) thread.daemon = True thread.start() self.send_json(202, {"task_id": task_id, "status": "pending"}) ``` ```python super().__init__(("127.0.0.1", port), WorkerHandler) ``` ### Technical Analysis The task submission endpoint does not authenticate callers or check whether they are authorized to use the selected worker. Submitted task descriptions are subsequently passed to OpenClaw, Hermes, DeerFlow, an arbitrary configured CLI, or an external worker. Although the server binds to loopback, loopback binding is not an authentication boundary. Other local processes can access the endpoint. A malicious website may also be able to issue a simple cross-origin request by using a permitted content type, because the server parses the body as JSON without validating `Content-Type` or `Origin`. Th ...[truncated 1618 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Generate a cryptographically random authentication token for each worker. 2. Require `Authorization: Bearer <token>` for task submission, task status, task results, and state endpoints. 3. Store tokens with restrictive filesystem permissions and never place them in logs. 4. Reject requests with unexpected `Origin` headers and require `Content-Type: application/json`. 5. Generate task identifiers exclusively on the server; do not accept caller-selected IDs. 6. Add maximum request-body sizes, task concurrency limits, and rate limits. 7. Run each worker under a restricted operating-system identity or sandbox. 8. Restrict each engine to the minimum filesystem and command capabilities required for its role. 9. Consider using a Unix-domain socket with filesystem permissions instead of an unauthenticated TCP endpoint. ]]>
