[Security][High] No role-based authorization — editor role is never enforced
#10
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High · Type: Security / access control
Problem
isLoggedIn(server/src/utils/auth.js:81) only verifies that the JWT is valid. Every admin route is gated byisLoggedInalone (server/src/router/v1/admin/admin.routes.js:15). The system defines two roles (admin,editor), but no route ever checksreq.user.role— the only role logic is two narrow "last admin" guards inadmin.controller.js.Impact
A low-privilege
editorcan call any admin endpoint:POST /admin/users— create a new adminPUT /admin/users/:id— promote themselves to adminDELETE /admin/users/:id— delete other usersPUT /admin/site-mode— flip the site in/out of maintenanceThis is a privilege-escalation hole: any authenticated non-admin effectively has full admin power.
Suggested fix
Add a role-gate middleware and apply it to admin-only routes (
/users/*,/site-mode, and anything else that should be admin-only):Decide per-route which operations
editormay perform (likely content: posts/wiki) vs. admin-only (users, site mode, settings).