#0104
An internal notes service stores both public and admin-only notes. The getAdminNote endpoint accepts a requesting user ID and a note ID.
Notes flagged with adminOnly: true should be restricted to users with the admin role. However, the current implementation returns every note regardless of the adminOnly flag.
Regular users can read sensitive admin notes by simply guessing or enumerating note IDs.
Mixing public and privileged resources in the same endpoint without role checks is a common mistake. It allows regular users to access admin-only data simply by knowing or guessing an ID.
getAdminNote so that adminOnly notes are only returned when the requesting user has role: 'admin'.'Forbidden' when a non-admin user requests an adminOnly note.'Not found' when the note or user does not exist.getAdminNote('alice', 'note-secret', notes, users)// note-secret has adminOnly: true, alice has role: 'user'// → throws Error('Forbidden')
getAdminNote('superadmin', 'note-secret', notes, users)// superadmin has role: 'admin'// → returns note object
'Forbidden' and 'Not found'.