The vulnerability lies in the disclosure of sensitive host-specific paths (configPath and stateDir) to non-admin users connecting to the OpenClaw Gateway. The analysis of the provided patch 676b748056b5efca6f1255708e9dd9469edf5e2e reveals the root cause.
The function buildGatewaySnapshot in src/gateway/server/health-state.ts was responsible for assembling a "snapshot" of the gateway's status. In its vulnerable form, it always included the configPath and stateDir in the snapshot object it created.
This snapshot was then used by the attachGatewayWsMessageHandler function in src/gateway/server/ws-connection/message-handler.ts. This handler, upon a successful client connection (hello-ok), would send this snapshot to the client. Since there was no privilege check before creating and sending the snapshot, any authenticated user, regardless of their administrative status, would receive these sensitive paths.
The fix involves two parts:
- The
buildGatewaySnapshot function was modified to accept an opts object with an includeSensitive boolean property. The sensitive information is now only added to the snapshot if includeSensitive is true.
- The
attachGatewayWsMessageHandler function was updated to check if the connecting client's scopes include ADMIN_SCOPE. It then calls buildGatewaySnapshot with includeSensitive set to true only for admin users.
Therefore, during exploitation, a non-admin user would connect, and the attachGatewayWsMessageHandler would call buildGatewaySnapshot, which would then return the sensitive data. These two functions are central to the vulnerability.