T09 · Insecure Skill Coding Practices
- Location
src/server.mjs:84- Finding
Unauthenticated API May Be Exposed on All Network Interfaces
- Content
View full analysis
console.log(`🔥 ClawMeter running at http://localhost:${config.port}`)); ``` ### Technical Analysis The server starts without specifying a listening hostname. Depending on the Node.js runtime and operating-system configuration, this can bind the Express application to all available interfaces rather than exclusively to the loopback interface. This behavior conflicts with the documentation's claim that the service is local-only. The application also implements no authentication or authorization for its API endpoints. Exposed endpoints include: - `/api/summary` - `/api/daily` - `/api/sessions` - `/api/models` - `/api/top-sessions` - `/api/alerts` - `POST /api/ingest` These endpoints reveal session identifiers, agent names, model and provider names, token counts, timestamps, spending data, budgets, and alert history. The ingestion endpoint also allows any reachable client to trigger filesystem scanning and database processing. ### Attack Path 1. A user starts ClawMeter on a workstation or server. 2. The application listens on port 3377 without explicitly restricting the listener to `127.0.0.1` or `::1`. 3. An attacker on a reachable network discovers port 3377 through service enumeration or a direct request. 4. The attacker requests endpoints such as `/api/sessions`, `/api/models`, and `/api/alerts`. 5. The application returns private usage metadata without authentication. 6. The attacker may repeatedly invoke `POST /api/ingest`, causing repeated session-directory scans, JSONL parsing, aggregate rebuilding, and database writes. If the port is exposed through a firewall, container mapping, reverse proxy, or cloud security group, the same path may be exploitable remotely. ### Impact Assessment An unauthenticated at ...[truncated 493 chars]- Remediation
View remediation
{ console.log(`ClawMeter running at http://${host}:${config.port}`); }); ``` 2. If IPv6 loopback support is required, configure it deliberately and test that the service is not reachable through external interfaces. 3. Add authentication before supporting remote access. Suitable controls include: - A random bearer token stored outside source control - Authenticated reverse-proxy access - Mutual TLS for managed deployments - SSO for team environments 4. Require authorization for `POST /api/ingest` and apply rate limiting. 5. Add request throttling and concurrency controls so repeated ingestion requests cannot overlap or exhaust resources. 6. Update startup logs and documentation so they report the actual listening address rather than implying a localhost-only binding. 7. Add an automated test that verifies the default service is unreachable through non-loopback interfaces. ]]>
