The vulnerability (CVE-2025-3230) concerns Mattermost's failure to properly invalidate personal access tokens (PATs) upon user deactivation, allowing continued system access for deactivated users. The analysis of the provided commit 65343f84a7830fa8078fe3df879fca924e4fac01 reveals that the core issue lay within the (*app.App).UpdateActive function located in server/channels/app/user.go.
The patch modifies this function by reordering the execution of a.InvalidateCacheForUser(user.Id). Previously, this cache invalidation call was placed after critical deactivation steps (like session revocation). The vulnerability arose because token validation mechanisms likely relied on this cache to check a user's active status. With the delayed invalidation, these mechanisms could read stale data, perceive a deactivated user as still active, and thus validate their PATs.
The fix moves the cache invalidation to occur before the main deactivation logic if the user is being set to inactive (!active). This ensures that any system component checking the user's status via the cache will immediately see the updated (deactivated) status, leading to the correct invalidation or rejection of their PATs.
The E2E test added in the commit (deactivated_user_spec.ts) further supports this by explicitly testing the scenario: creating a PAT, deactivating the user, and then attempting to use the PAT, expecting it to fail. This confirms that the change in (*app.App).UpdateActive rectifies the token validation loophole.
Therefore, (*app.App).UpdateActive is identified as the function containing the flawed logic that led to the vulnerability. While it doesn't directly process malicious input for this specific flaw, its incorrect sequencing of cache invalidation during the user deactivation process created the vulnerable state exploited by continued use of PATs.