---
date: 2026-10-18
Evidence basis: static code analysis
---

# VBMS Roles & Permissions Matrix (Discovery 01)

Evidence basis: static code analysis. No SQL was executed against any database; all
grant/seed statements below were read from migration files and seeding scripts only.

---

## 1. Role Catalog

### 1.1 Assignable roles (`users.role` ENUM — 10 roles)

Source: `backend/src/scripts/migration_step28_house_keeping_role.sql:15` (final ENUM state;
step2 added `admin`, `migration_contact_login.sql:19` added the customer roles, step28 added `house_keeping`).

| # | Role | Intended population | roles row + child_permissions seeded by |
|---|------|--------------------|------------------------------------------|
| 1 | `super_admin` | Operators/owners; bypasses every permission check | step1 (grants); recoverPermissions.js:191 |
| 2 | `admin` | Internal administrators (all but `audit.view`) | step1:391; recoverPermissions.js:197 |
| 3 | `coordinator` | Internal coordinators: jobs, attendance, reviews, reports | step27:14,131 |
| 4 | `field_member` | Field technician: assigned tickets + own attendance | step27:18,163 |
| 5 | `vbms_reviewer` | VBMS-stage ticket review | step27:23,180 |
| 6 | `cub_reviewer` | CUB-stage ticket review | step27:28,202 |
| 7 | `customer_admin` | Customer portal administrator | step27:33,224 (+ step43:49) |
| 8 | `customer_viewer` | Customer portal read-only | step27:38,240 (+ step43:54) |
| 9 | `customer_operator` | Customer portal operator | step27:43,256 (+ step43:59) |
| 10 | `house_keeping` | Housekeeping staff: tickets + attendance | step28:20,40 |

### 1.2 Pseudo-role (not in the ENUM)

- **`customer_contact`** — display/user-type label only: derived in the users list when a
  user is linked to `customer_contacts` (`userMgmtRoutes.js:37`), and included in
  `CUSTOMER_ROLES` scope arrays (`jobRoutes.js:15`, `customerRoutes.js:14`, `rbac.js:62`).
  Contact logins always get a real ENUM role via `login_role` (default `customer_viewer`).
  Total named strings across the system: **11** (10 assignable + 1 pseudo).

### 1.3 Role definition store

- Flat grants: `role_permissions (role, permission_id)` table — this is the **only** store
  the backend enforces (`rbac.js:13-18`).
- Granular grants: `roles.child_permissions` JSON — **frontend-only** gating
  (`auth.js:44-54` loads it, but no backend middleware reads it).

---

## 2. Permission Catalog (64 permissions)

Authoritative catalog: `recoverPermissions.js:8-73` (BASE_PERMISSIONS, 64 entries).
SQL migrations seed 63 of them; **`settings.personalization` exists only in
recoverPermissions.js:55 — no SQL migration inserts that permission row** (step1 has only
`settings.view`/`settings.edit`, `migration_step1_schema.sql:367-368`), so on a SQL-only
database the grants referencing it are silently no-ops.

| Module | Permissions | Count |
|--------|-------------|-------|
| company | view, create, edit, delete | 4 |
| customer | view, create, edit, delete | 4 |
| state | view, create, edit, delete | 4 |
| location | view, create, edit, delete | 4 |
| employee | view, create, edit, delete | 4 |
| job | view, create, edit, assign, reassign, cancel | 6 |
| attendance | view, edit, override | 3 |
| leave | view, approve | 2 |
| holiday | view, create, edit, delete, override | 5 |
| review | vbms, cub | 2 |
| mis | view, export | 2 |
| salary | view, edit | 2 |
| reports | view, export | 2 |
| settings | view, edit, personalization | 3 |
| user | view, create, edit, delete | 4 |
| audit | view | 1 |
| notification | view, manage | 2 |
| feedback | view, create, edit, delete, send, view_responses, download_pdf | 7 |
| documentation | view, dev, export | 3 |
| **Total** | | **64** |

### 2.1 Enforced vs. unenforced

**Enforced by backend middleware (48 distinct permissions):** every value returned by
`requirePermission(...)` across `backend/src/routes/*.js` (plus `requireAnyPermission`
groups: `['job.edit','attendance.edit']`, `['job.view','job.edit']`,
`['review.vbms','review.cub']`).

**Never enforced by any backend route (16):**

| Permission | Actual enforcement reality |
|------------|---------------------------|
| `leave.view` | leave list uses `attendance.view` (`attendanceRoutes.js:272`) |
| `leave.approve` | approve/reject uses `attendance.edit` (`attendanceRoutes.js:330`) |
| `job.assign`, `job.reassign` | assign/reassign use `job.edit` (`jobRoutes.js:1107,1159`) |
| `employee.delete` | member delete uses `employee.edit` (`memberRoutes.js:438`) |
| `user.delete` | user delete uses `user.edit` (`userMgmtRoutes.js:265`) |
| `attendance.override` | attendance update uses `attendance.edit` (`attendanceRoutes.js:173`) |
| `salary.view`, `salary.edit` | salary routes use `mis.view`/`mis.export` (`misRoutes.js:129,159`) |
| `reports.view`, `reports.export` | frontend menu gating only; no backend route checks them |
| `settings.personalization` | preferences route is `requireAuth`-only (`preferenceRoutes.js:7,23`) |
| `documentation.view/dev/export` | no documentation route file exists; content is frontend-static |
| `feedback.download_pdf` | never referenced by any route |

---

## 3. Role × Permission Matrix

Effective state = migration order step1 → step23 → step24 → step25 → **step27 (DELETE+reseed
7 roles)** → step28 → step43 → step48 → step50, plus `migration_contact_login.sql` grants
for customer roles. `INSERT IGNORE`/`DELETE` semantics applied. Legend: **✓** granted, — not
granted. All cells for `super_admin` are ✓ (code bypass at `rbac.js:11`, not just grants).

| Permission | super_admin | admin | coordinator | field_member | vbms_reviewer | cub_reviewer | customer_admin | customer_viewer | customer_operator | house_keeping |
|---|---|---|---|---|---|---|---|---|---|---|
| company.* (4) | ✓ | ✓ | — | — | — | — | — | — | — | — |
| customer.view | ✓ | ✓ | ✓ | — | — | — | ✓ | ✓ | ✓ | — |
| customer.create/edit/delete | ✓ | ✓ | — | — | — | — | ✓ | — | — | — |
| state.view | ✓ | ✓ | ✓ | — | — | — | ✓ | ✓ | ✓ | — |
| state.create/edit/delete | ✓ | ✓ | — | — | — | — | — | — | — | — |
| location.view | ✓ | ✓ | ✓ | — | — | — | ✓ | ✓ | ✓ | — |
| location.create/edit/delete | ✓ | ✓ | — | — | — | — | — | — | — | — |
| employee.view | ✓ | ✓ | ✓ | — | — | — | ✓ | ✓ | ✓ | — |
| employee.create/edit/delete | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| job.view | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| job.create | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| job.edit | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| job.assign / job.reassign | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| job.cancel | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| attendance.view | ✓ | ✓ | ✓ | ✓ | — | — | ✓ | ✓ | ✓ | ✓ |
| attendance.edit | ✓ | ✓ | ✓ | ✓ | — | — | — | — | — | ✓ |
| attendance.override | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| leave.view | ✓ | ✓ | ✓ | ✓ | — | — | — | — | — | ✓ |
| leave.approve | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| holiday.view | ✓ | ✓ | ✓ | — | — | — | — | — | — | — |
| holiday.create/edit/delete | ✓ | ✓ | — | — | — | — | — | — | — | — |
| holiday.override | ✓ | ✓ | — | — | — | — | — | — | — | — |
| review.vbms | ✓ | ✓ | ✓ | — | ✓ | — | — | — | — | — |
| review.cub | ✓ | ✓ | ✓ | — | — | ✓ | ✓ | — | — | — |
| mis.view / mis.export | ✓ | ✓ | ✓ | — | ✓ | ✓ | — | — | — | — |
| salary.view / salary.edit | ✓ | ✓ | — | — | — | — | — | — | — | — |
| reports.view / reports.export | ✓ | ✓ | ✓ | — | ✓ | ✓ | ✓ | ✓ | ✓ | — |
| settings.view | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | — | — | ✓ |
| settings.edit | ✓ | ✓ | — | — | — | — | — | — | — | — |
| settings.personalization* | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | — | — | ✓ |
| user.view/create/edit/delete | ✓ | ✓ | — | — | — | — | — | — | — | — |
| audit.view | ✓ | — | — | — | — | — | — | — | — | — |
| notification.view | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| notification.manage | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | **—** ⚠ |
| feedback.view/create/edit/delete/send | ✓ | ✓ | — † | — | — | — | — | — | — | — |
| feedback.view_responses | ✓ | ✓ | ✓ | — | ✓ | ✓ | — | — | — | — |
| feedback.download_pdf | ✓ | ✓ | — † | — | — | — | — | — | — | — |
| documentation.view/export | ✓ | ✓ | — † | — † | — † | — † | — | — | — | — |
| documentation.dev | ✓ | ✓ | — | — | — | — | — | — | — | — |

**Counts (excluding super_admin bypass):** admin 63 · coordinator 30 · field_member 8 ·
vbms_reviewer 9 · cub_reviewer 9 · customer_admin 14 · customer_viewer 10 ·
customer_operator 10 · house_keeping 7.

\* `settings.personalization` grant rows exist only if `recoverPermissions.js` was run
(permission row otherwise missing from `permissions`).
† **Seeding-order regression:** step24 granted coordinator `feedback.view/send/download_pdf`
and step25 granted the four operational roles `documentation.view/export`, but **step27 runs
later, DELETEs all grants for those roles and reseeds without them**
(`migration_step27_mobile_role_permissions.sql:51-55`). After step27, coordinator keeps only
`feedback.view_responses`; operational roles lose all `documentation.*` and coordinator loses
`holiday.override` from step1 as well. A DB repaired via `recoverPermissions.js` (which
re-adds documentation grants, lines 203-223) will differ from a freshly migrated one.

⚠ step50 grants `notification.manage` to vbms/cub/field/coordinator but **not**
`house_keeping` (`migration_step50_notification_manage.sql:16`) — house_keeping can list
notifications but gets 403 on mark-read/mark-all-read/delete (`notificationRoutes.js:42,68,94`).

### 3.1 child_permissions JSON (frontend gating state, post-migration)

- coordinator: employee/job(all 4 children)/attendance/review(vbms+cub+feedback)/reports/settings all-true; documentation key lost at step27 (see †).
- field_member / house_keeping: job.view + my-assignments edit; attendance view/edit; leaves view; settings view+personalization edit (step27:163, step28:40).
- vbms_reviewer: review.vbms view+edit (step48:27), review.cub false; cub_reviewer inverse (step48:31).
- customer_admin: job + master(customers CRUD) + attendance read-only + employee all-false + reports open (step43:84-105) + review.cub view+edit (step48:35-42).
- customer_viewer/operator: job + master(customers view) + attendance read-only + reports open (step43).

---

## 4. Endpoint × Permission Map (from route middleware)

Mount points: `app.js:107-131`. `requireAuth` = authentication only (no permission check).
`super_admin` bypasses every `requirePermission`/`requireAnyPermission` (`rbac.js:11,39`).

### auth (`/api/auth`, authRoutes.js) — public/low-gate
| Endpoint | Middleware |
|---|---|
| POST /login, GET /check-username/:username, POST /forgot-password, GET+POST /reset-password/:token | **none (public)** |
| GET /me, POST /logout, POST /change-password | requireAuth only |

### preferences, profile, search, dashboard
| Endpoint | Middleware |
|---|---|
| GET/PUT /api/preferences | requireAuth only (`preferenceRoutes.js:7,23`) |
| GET/PUT/POST/DELETE /api/profile/** | requireAuth only (self-scoped by `req.user.id`) |
| GET /api/search | requireAuth only (`searchRoutes.js:15`) — **no permission, no scope on locations/customers/members queries** |
| GET /api/dashboard/stats | requireAuth only (`dashboardRoutes.js:79`) — scope filter applied inside (99-115) |

### companies / states / locations (CRUD = view/create/edit/delete respectively)
`GET /`+`GET /:id` → `*.view`; `POST /` → `*.create`; `PUT /:id` → `*.edit`;
`DELETE /:id` → `*.delete` (companyRoutes 10/45/66/87, stateRoutes 10/57/80/103,
locationRoutes 10/58/96/123). No row scoping (admin/staff-only permissions).

### customers (`customerRoutes.js`)
| Endpoint | Permission | Scope check |
|---|---|---|
| GET / , GET /branches/all | customer.view | ✓ list filter (37-44) |
| GET /:id | customer.view | **✗ none (68)** ⚠ |
| POST / | customer.create | n/a |
| PUT /:id | customer.edit | **✗ none (157)** ⚠ |
| DELETE /:id | customer.delete | **✗ none (194)** ⚠ |
| GET contacts/branches/locations/contacts (nested reads) | customer.view | ✗ per-item |
| POST/PUT/DELETE nested contacts, branches, locations | customer.edit | ✗ per-item |
| POST/PUT/DELETE contact login creation (`login_role` in body) | customer.edit | ⚠ role value unvalidated (216,232,348,365,588,604,737,756) |

### members (`memberRoutes.js`)
| Endpoint | Permission | Scope |
|---|---|---|
| GET / , GET /all-documents, /all-member-locations, /:id, /:memberId/documents|police-docs|locations|skills | employee.view | list ✓ (141-154); GET /:id ✓ (191-203) |
| POST / , PUT /:id, DELETE /:id | employee.create / employee.edit / employee.edit | PUT/DELETE: **✗ no scope**; `login_role` unvalidated (263,291,354,397-399) ⚠ |
| POST/DELETE nested docs, locations, skills, photo, police-doc | employee.edit | ✗ |

### jobs (`jobRoutes.js`)
| Endpoint | Permission | Scope |
|---|---|---|
| GET / , GET /daily-tasks, /sidebar-stats, /by-member/:id, /check-leave, /branch-locations, /:id/daily-tasks, /:id/location-pings, /ticket/:id/redo-history | job.view | lists ✓ (598-611, 503-510); **GET /:id ✗ (772)** ⚠ |
| GET /members-by-location | job.view OR job.edit | ✓ (648) |
| POST / , PUT /:id, /auto-assign, tracking, checkin/checkout (job-level), photos, checklists, submit, generate/manual daily-tasks, PUT daily-task | job.create / job.edit | ✗ per-item |
| POST /:id/assign, /:id/reassign | job.edit | ✗ (assign permission unused, see §2.1) |
| POST daily-task photo(s), checkin, checkout, tracking/ping | job.edit OR attendance.edit | ✗ ownership of `assigned_member_id` not verified (1997-2069) ⚠ |
| DELETE /:id, DELETE daily-task | job.cancel | ✗ |
| POST /ticket/:ticketId/redo | requireAuth + inline `role === 'super_admin'` (2159-2162) | — |

### attendance (`attendanceRoutes.js`)
| Endpoint | Permission | Scope |
|---|---|---|
| GET / , /daily-summary, /leaves, /capacity, /daily-attendance, /capacity-summary, /cron-status | attendance.view | ✓ (66-73, 272-…, 414, 491) |
| POST /checkin, /checkout | attendance.edit | ⚠ `member_id` from body trusted (99-126, 137) |
| PUT /:id | attendance.edit | ✗ (173) |
| POST/PUT leaves, POST capacity, POST refresh-attendance, PUT cron-schedule | attendance.edit | approve = any holder incl. field_member (330) ⚠ |

### reviews (`reviewRoutes.js`)
| Endpoint | Permission | Scope |
|---|---|---|
| GET /pending, /job/:jobId, /ticket/:ticketId, /history/:jobId | review.vbms OR review.cub | pending list ✓ (98-102); stage overridable by query (55-56) |
| POST /vbms/… (approve, rework), /vbms/:jobId/* | review.vbms | ✗ |
| POST /cub/ticket/:id/approve|comment|feedback, /cub/:jobId/* | review.cub | **✗ approve actions unscoped (442)** ⚠ |

### MIS, feedback, holiday, notifications, audit, users, settings, mail-formats, integrations, service-types, materials, material-types
| Group | Permission(s) | Notes |
|---|---|---|
| GET/POST mis/* (monthly, generate, salary, member reviews) | mis.view / mis.export | salary guarded by mis.*, not salary.* |
| feedback templates CRUD | feedback.view/create/edit/delete | GET /templates/active **public** (22); GET /public/:token + POST /public/:token/submit **public by design** (256,297) |
| feedback requests list (3 routes) | feedback.view_responses | ✗ customer scope on /requests/customer/:customerId (117) |
| POST /requests | feedback.send | ✗ customer scope |
| holiday CRUD + rules | holiday.view/create/edit/delete | list ✓ (128) |
| holiday overrides (4 routes) | holiday.override | list ✓ (360) |
| holiday /resolve, /availability | requireAuth only (467,488) | intentional for mobile |
| notifications GET / + /unread-count | notification.view | self-scoped by user_id (12-13) |
| notifications read/unread/read-all/delete | notification.manage | self-scoped (45); house_keeping 403 (see §3 ⚠) |
| audit GET / and /:id | audit.view | super_admin + admin only |
| users list/get/scopes/roles/permissions | user.view | |
| users POST | user.create | ⚠ `role` from body unvalidated (200-207) |
| users PUT /:id, DELETE /:id, scopes CRUD, roles POST/PUT/DELETE | user.edit | ⚠ PUT allows any role incl. super_admin (233-235); roles PUT replaces role's whole permission set (581) |
| PUT /roles/:id/permissions | user.edit | ⚠ arbitrary permission set incl. own role (676-698) |
| settings GET / | settings.view | |
| settings PUT / | settings.edit **+ inline role whitelist** super_admin/admin (25) | defense in depth |
| mail-formats CRUD | settings.view / settings.edit | delete uses settings.edit |
| integrations GET /email | settings.view | returns SMTP user + masked password |
| integrations POST /email | settings.edit (+ super_admin/admin inline, integrationRoutes.js:78) | |
| service-types, materials, material-types | job.view/create/edit (delete = job.edit) | materials list + GET /:id scoped (materialRoutes 18, 233-236); writes unscoped |
| assetRoutes (GET/POST/PUT/DELETE) | requireAuth only (9,40,63,87) | **not mounted in app.js** — dead code |

---

## 5. Frontend Gating Rules

The frontend uses a three-layer decision; **only layer 1 has a backend counterpart**.

1. **`super_admin` bypass** — `RoleGuard.jsx:57,71,94`, `menu.js:50,81,106`,
   `canDo.js:43,49,100`, `usePermission.js:20,28,33`. Always allow.
2. **`child_permissions` JSON (exclusive priority when the module key exists)** —
   - `RoleGuard.jsx:26-34` `isChildAccessibleByJson`: *any* action true ⇒ accessible;
     applied at `RoleGuard.jsx:92-97` (`jsonChildAccess !== null` wins over flat perms).
   - `menu.js:48-72` `canAccessChild`: JSON first (any action true → allow; all-false →
     deny; empty object → falls through), then flat `child.permissions` fallback;
     `childPermStrings === undefined` ⇒ accessible to all authenticated (menu.js:68).
   - `canDo.js:37-104` `canDo`: super_admin first; non-CRUD actions (send, view_responses,
     download_pdf, export…) check **flat** perms only (42-45); CRUD from JSON with
     all-enabled semantics (85) and "module configured but action undefined ⇒ deny" (92-94).
   - `usePermission.js:19-25` routes `hasPermission` through `canDo`.
3. **Flat `permissions[]` fallback** — from `modules.js:262-271`
   (`canAccessChildByKey`: `undefined` = open, `[]` = nobody, else `some()` overlap) and
   `menu.js:67-71`.

**Menu/sidebar wiring:** `Sidebar.jsx:45,277` filter children via `canAccessChild`.
**Scope UI:** `useScope.js:17` `isUnscopedRole = ['super_admin','admin','coordinator',
'field_member','house_keeping','vbms_reviewer','cub_reviewer']` — mirrors backend
`NON_SCOPED_ROLES` (`dashboardRoutes.js:10-13`) and `rbac.js:77`.

**Divergence risks:** disabling a child in `child_permissions` hides it in the UI but does
**not** block direct API calls (backend checks only flat `role_permissions`); conversely,
flat grants without a child key (e.g. `employee.view` for customer roles, step43) feed report
APIs while the module stays hidden (intentional, documented in step43:26-28).

---

## 6. Customer Scoping Rules

**Scope source:** `employee_scopes` rows (`scope_type` = `customer` | `location`), loaded
into `req.user.scopes` per request (`auth.js:37-41`); customer name attached (`auth.js:70-81`).

**Canonical `getScopeIds` semantics** (identical copy in 9 route files — `jobRoutes.js:17`,
`customerRoutes.js:16`, `attendanceRoutes.js:15`, `memberRoutes.js:19`,
`materialRoutes.js:18`, `holidayRoutes.js:105`, `reviewRoutes.js:19`, `dashboardRoutes.js:15`):
- `super_admin` / `admin` → `null` (no restriction)
- customer-type scopes present → array of ids (filter)
- **customer role with zero rows → `[]` ⇒ deny-all** (`1 = 0`)
- staff roles → `null`
- `dashboardRoutes.js:10` uses explicit `NON_SCOPED_ROLES` list instead of role checks.

**Inconsistency:** `searchRoutes.js:7-13` returns `null` when `matching.length === 0`
(line 11) — no `CUSTOMER_ROLES` deny-all branch — so a customer login **with no scope rows
sees all jobs** in search results; and its `locations`/`members`/`customers` queries
(`searchRoutes.js:26-39`) are never scope-filtered at all.

**Where scoping is enforced (list endpoints):** jobs (jobRoutes 598-611), daily-tasks
(503-510), customers (customerRoutes 37-44), attendance family (attendanceRoutes 66-73,
272+, 414, 491), members list + GET /:id (memberRoutes 141-154, 191-203), materials
GET /:id (materialRoutes 233-236), holidays (128, 360), dashboard stats (99-115),
reviews pending (98-102), notifications (self user_id, notificationRoutes 12-13).

**Where scoping is absent (IDOR surface):** `GET/PUT/DELETE /customers/:id`
(customerRoutes 68,157,194), `GET /jobs/:id` (jobRoutes 772 — returns full detail incl.
customer phone, 841-858), member `PUT/DELETE /:id`, material `POST/PUT/DELETE`,
**all review approve/rework/comment actions** (reviewRoutes 305,355,442,508,549),
`/feedback/requests/*` reads (117,127), job assign/reassign/auto-assign.

**Dead abstraction:** `enforceCustomerScope()` (`rbac.js:69-106`) is exported but **never
imported by any route file** (only referenced in a comment, `dashboardRoutes.js:9`);
every route re-implements its own `getScopeIds` copy instead.

---

## 7. Risk Register

| # | Risk | Severity | Evidence |
|---|------|----------|----------|
| R1 | **Privilege escalation via unvalidated `login_role`**: `customer.edit` holder can create a `super_admin` login through contact/locations contact creation; `employee.create/edit` holder via member login; `user.create` via `role` in body | Critical | customerRoutes.js:216,232,588,604; memberRoutes.js:263,291,354; userMgmtRoutes.js:200-207 |
| R2 | **Arbitrary role-permission grant**: `PUT /roles/:id/permissions` (user.edit) can grant any permission to any role including the caller's own (e.g. admin → audit.view); no protected-permission list | Critical | userMgmtRoutes.js:676-698; also PUT /roles/:id (581) |
| R3 | **IDOR on customer read/update/deactivate**: no scope check on `GET/PUT/DELETE /customers/:id` — scoped customer_admin can read/edit any customer | High | customerRoutes.js:68,157,194 |
| R4 | **IDOR on job detail**: `GET /jobs/:id` unscoped; returns assignments, photos, check-ins, customer phone | High | jobRoutes.js:772,841-858 |
| R5 | **Leave self-approval**: `leave.approve` never enforced; approve path is `attendance.edit`, held by field_member/house_keeping → approve own leave; `member_id` also accepted from body | High | attendanceRoutes.js:330,332,353; step27:78 |
| R6 | **Cross-customer review sign-off**: `customer_admin` holds `review.cub` (step48:22-23) and approve endpoints have no scope check → can approve/sign off any customer's tickets | High | reviewRoutes.js:442-462; migration_step48_review_signoff_comment.sql:22-23 |
| R7 | **Search leaks unscoped data**: `/api/search` requireAuth-only, locations/members/customers queries unfiltered, and `getScopeIds` lacks deny-all for zero-scope customer logins | Medium | searchRoutes.js:7-13,15,26-39 |
| R8 | **Two-tier permission divergence**: backend enforces flat `role_permissions` only while UI tabs/buttons/menus are gated by `child_permissions` JSON — UI-off does not deny API; 16 catalog permissions are never enforced anywhere; `enforceCustomerScope` middleware is dead code | Medium | rbac.js:69,108; RoleGuard.jsx:73-97; menu.js:52-71; §2.1 |
| R9 | Plaintext `original_password` column written on every user create/update (customer, member, user management) | High (data exposure) | userMgmtRoutes.js:206,230; customerRoutes.js:232; memberRoutes.js:291,354 |
| R10 | Unauthenticated username enumeration + public password-reset token flow surface | Medium | authRoutes.js:172-186,199,275 |
| R11 | Dashboard `/stats` requireAuth-only (any role, incl. minimal) reaches full KPI aggregation (scoped for customer roles only) | Low | dashboardRoutes.js:79 |
| R12 | `house_keeping` missing `notification.manage` → mark-read 403 (seed gap) | Low | step50:16; notificationRoutes.js:42 |
| R13 | `assetRoutes` requireAuth-only with no permission checks — currently unmounted dead code; hazardous if ever mounted | Info | assetRoutes.js:9,40,63,87; app.js (no mount) |
| R14 | `settings.personalization` permission row absent from SQL seeds → grants silently no-op on SQL-migrated DBs | Info | step1:367-368; recoverPermissions.js:55 |
| R15 | job daily-task checkin/checkout accepts any ticket via `job.edit OR attendance.edit` without verifying `assigned_member_id` matches caller | Medium | jobRoutes.js:1997,2069 |
