The vulnerability lies in the application's failure to invalidate existing user sessions after a password change or reset. This allows an attacker with a stolen session cookie to maintain access to a user's account even after the user has changed their credentials.
To identify the vulnerable functions, I first compared the git tags of the vulnerable version v6.0.0 and the patched version v6.1.0. This revealed a key commit with the message "Wipe user sessions from DB on password reset/change." (db82035d619348949512dafdaf60c86037cafc9e).
Analyzing this commit showed the introduction of a new function, core.DeleteUserSessions, which is responsible for deleting a user's sessions from the database. The patch then adds calls to this new function in three specific locations that correspond to the scenarios described in the vulnerability report:
App.doResetPassword in cmd/auth.go: This function handles the forgot-password flow. The patch adds a call to DeleteUserSessions to invalidate all of the user's sessions upon a successful password reset.
App.UpdateUser in cmd/users.go: This function is used by administrators to update user details. The patch ensures that if an admin changes a user's password, all of that user's sessions are terminated.
App.UpdateUserProfile in cmd/users.go: This function is used by a user to update their own profile. The patch adds a call to DeleteUserSessions to terminate all other active sessions, keeping only the current one alive.
These three functions were the points of vulnerability because they modified user credentials without performing the necessary session invalidation, thus creating a window for unauthorized account persistence.