T05 · Unauthorized Access and Privilege Escalation
- Location
server.js:641- Finding
Unauthenticated Network Exposure of Sensitive OpenClaw Data
- Content
View full analysis
{ const { agentId, file } = req.params // Security: only allow .jsonl files, no path traversal if (!file.endsWith('.jsonl') || file.includes('/') || file.includes('..')) { return res.status(400).json({ error: 'Invalid file' }) } const filePath = path.join(OC, 'agents', agentId, 'sessions', file) let events = [] try { const content = fs.readFileSync(filePath, 'utf8') events = content.split('\n') .filter(l => l.trim()) .map(l => { try { return JSON.parse(l) } catch { return null } }) .filter(Boolean) .filter(e => !(e.type === 'message' && e.message?.model === 'delivery-mirror')) } catch (err) { return res.status(404).json({ error: err.message }) } res.json(events) }) ``` The log endpoint similarly returns local gateway logs without access control: ```js app.get('/api/log', (req, res) => { try { const content = fs.readFileSync(path.join(OC, 'logs', 'gateway.log'), 'utf8') res.json(content.split('\n').filter(Boolean).slice(-300)) } catch { res.json([]) } }) ``` The server is explicitly exposed on every IPv4 network interface: ```js app.listen(PORT, '0.0.0.0', () => { console.log(`\n🦞 OpenClaw API → http://localhost:${PORT}`) console.log(` Frontend dev → npm run dev (http://localhost:5173)\n`) }) ``` ### Technical Analysis The Express application does not install any authentication or authorization middleware before its `/api` routes. At the same time, `app.listen(..., '0.0.0.0')` makes TCP port 3721 reachable through all availab ...[truncated 2466 chars]- Remediation
View remediation
{ console.log(`OpenClaw API listening on http://${HOST}:${PORT}`) }) ``` 2. Require authentication before every `/api` endpoint. Use a securely generated token, authenticated local session, or trusted reverse proxy rather than a hardcoded credential. 3. Apply authorization checks to agent and session identifiers so users can access only explicitly permitted data. 4. If remote access is intentionally enabled: - Require TLS. - Use a strong authentication mechanism. - Restrict allowed source addresses with a firewall or allowlist. - Set explicit CORS and trusted-host policies. - Place the application behind an authenticated reverse proxy. - Do not rely on obscurity of the port. 5. Redact credential-like values from logs, tool arguments, tool results, conversations, and memory before returning them to the browser. 6. Return only the minimum fields required by each UI component. In particular, avoid returning full memory documents through the general `/api/data` response. 7. Add request rate limits and connection limits, especially for `/api/events`, session replay, and log endpoints. 8. Update the documentation to state exactly which interface is used, whether remote access is supported, and what sensitive information the dashboard exposes. ]]>
