The vulnerability CVE-2026-46437 in wger describes a scenario where API credentials (DRF authtokens and JWT refresh tokens) remain valid even after a user logs out or changes their password. The analysis focused on identifying the specific functions responsible for these actions and examining their implementation in the vulnerable version of the code.
The GitHub security advisory (GHSA-v3x9-6gg8-c2c9) explicitly points to wger/wger/core/views/user.py as the location of the 'logout implementation'. Upon reviewing the content of this file (which represents the patched version, but allows inference of the vulnerable state based on the advisory's description), the logout function was identified. This function primarily calls django_logout(request), which is responsible for clearing the Django session cookie. However, it lacks any explicit calls to invalidate or blacklist API tokens (both DRF authtokens and JWT refresh tokens).
The wger/wger/utils/api_token.py file contains functions like blacklist_jwt_refresh_tokens and the Token model for DRF tokens, indicating that the mechanisms for token invalidation exist within the application. The core of the vulnerability, in the context of logout, is that these existing invalidation mechanisms were not integrated into the logout function itself in the vulnerable version. Therefore, when a user logged out, their API tokens remained active, allowing an attacker who had stolen these tokens to maintain access.
Regarding the password change aspect, while the advisory states that API tokens remain valid after a password change, the provided information (commit diffs, file contents) did not offer a clear, direct patch or modification to a specific password change function that explicitly addresses the invalidation of API tokens upon password change. The commit 537f27467930fb3f788d8cb205c77ad3510c6d23 adds a test for session invalidation on password change, implying a fix exists, but the actual code change for that fix was not directly identifiable through the provided tools and commit messages. Without concrete evidence of the specific function modified to address API token invalidation during password changes, I cannot confidently include it in the list of vulnerable functions as per the guidelines. Therefore, the analysis focuses on the logout function, for which there is clear evidence of its role in the vulnerability based on the advisory and its implementation.
In summary, the logout function in wger/core/views/user.py is identified as vulnerable because its implementation in the affected versions failed to revoke API credentials, allowing them to remain valid after a user explicitly logged out.