T05 · Unauthorized Access and Privilege Escalation
- Location
backend/src/app.ts:115- Finding
Unauthenticated Administrative API Exposed on All Network Interfaces
- Content
View full analysis
{ res.json(listModels()); }); app.put("/api/models", async (req, res, next) => { try { const payload = parseRequest(modelSchema, req.body); const modelId = payload.modelId ?? payload.id; const nextModel = { ...payload, modelId, providerId: payload.providerId ?? payload.platform ?? "openai", platform: payload.platform ?? payload.providerId ?? "openai" }; res.json(await upsertModel(nextModel)); } catch (error) { next(error); } }); app.get("/api/channels", (_req, res) => { res.json(listChannels()); }); app.get("/api/memory/files", async (req, res, next) => { try { const query = parseRequest(memoryQuerySchema, req.query); res.json(await listMemoryFiles(query.agentId, query.category)); } catch (error) { next(error); } }); app.post("/api/services/control", (req, res) => { const payload = parseRequest(gatewayServiceControlSchema, req.body); res.json(controlGatewayService(payload.action)); }); } ``` ```ts const port = Number(process.env.PORT ?? 4800); const app = createApp(); app.listen(port, () => { console.log(`OpenClaw gateway running on http://localhost:${port}`); }); ``` ### Technical Analysis No authentication or authorization middleware is registered before the administrative routes. The `securityConfig.accessPasswordSet` setting is only stored as state and is not enforced by request middleware. Calling `app.listen(port)` without a host ...[truncated 1586 chars]- Remediation
View remediation
{ console.log(`Gateway listening on 127.0.0.1:${port}`); }); ``` 5. Require an explicitly configured secure deployment mode before binding to a non-loopback interface. 6. Place remote access behind an authenticated TLS reverse proxy and firewall port 4800 from untrusted networks. 7. Replace unrestricted `cors()` with a strict allowlist and reject requests with untrusted `Origin` headers. 8. Add rate limiting, request auditing, authorization tests, and alerts for configuration or service-control operations. 9. Remove application-level `sudo` fallbacks unless a narrowly scoped operational requirement has been documented and reviewed. ]]>
