GHSA-vjc7-jrh9-9j86 9router has unauthenticated CRUD on /api/providers and Full API Key Leak via /api/usage/stats
title: Unauthenticated CRUD on /api/providers and Full API Key Leak via /api/usage/stats
product: 9Router
version: <= 0.4.41
severity: critical
cve_request: trueSummaryMultiple critical API security vulnerabilities were discovered in 9Router's Next.js dashboard. The `/api/providers` endpoints lack authentication entirely, allowing anyone to create, read, update, and delete provider connections. Additionally, `/api/usage/stats` exposes full plaintext API keys, and `/api/usage/request-logs` + `/api/usage/request-details` expose all users' request history and full conversation contents (including system prompts, user messages, assistant responses) without authentication.Affected Endpoints| Endpoint | Method | Issue |
|---|---|---|
| `/api/providers` | GET | Lists all provider connections with partial credentials, OAuth tokens, account IDs |
| `/api/providers/:id` | GET | Read any single provider detail (IDOR) |
| `/api/providers` | POST | Create arbitrary provider connections with attacker-controlled API keys |
| `/api/providers/:id` | PUT | Modify any existing provider connection |
| `/api/providers/:id` | DELETE | Delete any provider connection |
| `/api/usage/stats` | GET | Exposes full plaintext API keys, per-account usage breakdown, cost data |
| `/api/usage/request-logs` | GET | Exposes all users' request logs (model, tokens, cost, timestamp, provider) |
| `/api/usage/request-details/:id` | GET | Exposes full conversation turns including system prompts, user messages, assistant responses |
| `/api/version` | GET | Exposes current version info |
| `/api/models` | GET | Exposes full model routing catalog |
| `/api/v1/models` | GET | Exposes model list |ImpactCritical: Provider CRUD without authenticationAn attacker can:**Add a malicious provider** — inject a provider that proxies through their server, capturing all prompts, responses, and API keys routed through 9Router**Modify existing providers** — replace API keys with attacker-controlled ones, redirect traffic**Delete all providers** — cause complete denial of service**Read all provider configurations** — harvest partial credentials, GitHub Copilot OAuth tokens, Cloudflare account IDs, email addressesCritical: Full API key leak via /api/usage/statsThe endpoint returns complete API key strings (e.g., `sk-...`) in plaintext alongside usage data per key, enabling unauthorized use of connected AI provider accounts.Critical: Conversation history leak`/api/usage/request-details` returns the full conversation history of other users' AI sessions, including system prompts, user messages, assistant responses, tool calls, and reasoning traces.Steps to Reproduce1. Unauthenticated read of all providersReturns all provider connections with email addresses, auth type, account IDs, and partial API key prefixes.2. Create a provider without authenticationReturns the created connection object with a new UUID and `isActive: true`.3. Modify an existing provider without authenticationReturns the updated connection object.4. Delete a provider without authenticationReturns `{"message":"Connection deleted successfully"}`.5. Read full usage stats with API keysReturns full API key strings, per-account token/cost breakdown, recent requests.6. Read request logsReturns paginated request logs with timestamps, models, providers, user emails, token counts.7. Read full conversationReturns complete conversation turns for that request.8. Read version infoReturns `{"currentVersion":"0.4.19","latestVersion":"0.4.45","hasUpdate":true}`.Root CauseThe Next.js API routes under `src/app/api/*` lack authentication middleware on several endpoints. Specifically:`/api/providers/*` — No auth check before CRUD operations on provider connections stored in the database`/api/usage/stats` — No auth check before returning aggregated usage data including full API keys`/api/usage/request-logs` — No auth check before returning request history`/api/usage/request-details/:id` — No auth check before returning full conversation contentsSuggested FixAdd authentication middleware to all `/api/providers/*` routes (GET, POST, PUT, DELETE)Add authentication middleware to all `/api/usage/*` routesNever return full API key strings in any API response — return masked keys onlyNever return GitHub Copilot tokens or similar OAuth secrets in API responsesImplement proper authorization checks so users can only access their own dataAdd rate limiting to public endpointsResourceshttps://github.com/decolua/9router
CVSS v3.1 score: 10