+ "details": "### Summary\n\nThe User management API endpoints (`GET /api/v1/users` and `GET /api/v1/users/{id}`) are accessible to any authenticated user without admin/owner role verification, exposing all users' email addresses, roles, and account status.\n\n### Affected Endpoints\n\n1. **GET /api/v1/users** (UserController::index, line 94) — Lists ALL users with full details. No role check.\n2. **GET /api/v1/users/{id}** (UserController::show, line 126) — Shows any user's details by ID. No role check.\n\n### Root Cause (1-of-N Inconsistency)\n\nOther methods in the same controller properly check for the 'owner' role:\n\n- `store()` — `UserStoreRequest::authorize()` checks `auth()->user()->hasRole('owner')` ✓\n- `destroy()` — Explicitly checks `$this->repository->hasRole($admin, 'owner')` ✓\n\nBut `index()` and `show()` have no role check at all. The route group at `routes/api.php:734-747` has no admin middleware, only the global `auth:api` middleware.\n\n### Exposed Data\n\nThe `UserTransformer` (line 40-54) returns:\n- `email` — user's email address\n- `role` — user's role (owner/demo)\n- `blocked` — account blocked status\n- `blocked_code` — block reason\n- `created_at` / `updated_at` — timestamps\n\n### Impact\n\nAny authenticated user can:\n1. Enumerate ALL user accounts in the instance\n2. Harvest email addresses for phishing/social engineering\n3. Identify admin/owner accounts by role\n4. Determine which accounts are blocked\n\n### Exploitation\n\n```bash\n# List all users\ncurl -H \"Authorization: Bearer <any_user_token>\" https://instance/api/v1/users\n\n# View specific user details\ncurl -H \"Authorization: Bearer <any_user_token>\" https://instance/api/v1/users/1\n```\n\n### Suggested Fix\n\nAdd owner role checks to `index()` and `show()`, or restrict the route group with admin middleware:\n\n```php\n// Option 1: Add check in controller methods\npublic function show(User $user): JsonResponse\n{\n if (!$this->repository->hasRole(auth()->user(), 'owner') && auth()->user()->id !== $user->id) {\n throw new FireflyException('200025: No access to function.');\n }\n // ...\n}\n\n// Option 2: Add middleware to route group\nRoute::group(['middleware' => ['admin'], ...], ...)\n```",
0 commit comments