[Security][Medium] Stale JWT: demoted/deleted users keep access until token expiry #12
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: Medium · Type: Security / session
Problem
isLoggedIn(server/src/utils/auth.js:81) trustsidandrolestraight from the JWT and never re-checks the database. Because the token embedsroleand lastsJWT_EXPIRES_IN(default1d):This partly undermines the "cannot demote/delete the last admin" guards in
admin.controller.js:479,505.Suggested fix
For sensitive routes, load the user from the DB inside
isLoggedInand use the DBrole(or add a token/session version claim and compare it to a stored value, bumping it on role change / password reset / delete). The/auth/mehandler already re-fetches from the DB — the authorization path should too.