The vulnerability described is an improper privilege management issue in Apache StreamPipes, allowing a non-administrator to gain administrative control by manipulating JWT tokens to swap usernames. The patch for this vulnerability is in version 0.98.0. To identify the vulnerable functions, I analyzed the commits between the last vulnerable version (0.97.0) and the patched version (0.98.0).
By comparing the git tags release/0.97.0 and release/0.98.0, I identified a set of commits. Among them, commit 92db62386239f8b83bb9df1f83ac920f861ce7b5 with the message "refactor: remove UserService class and its associated methods" stood out as highly relevant.
This commit completely removes the UserService.java file. The removed class had a constructor UserService(String email) that fetched user details from the database based on the provided email. This aligns perfectly with the vulnerability description, where an attacker could manipulate their user identifier (email) to impersonate an administrator. The application would then use this UserService object, believing it's interacting with the legitimate administrator.
The removal of the entire class indicates that this was the core of the vulnerability, and the fix involved a significant refactoring of the user management logic to avoid this insecure pattern. Therefore, the constructor of the UserService class is identified as the primary vulnerable function, and the getPassword method is also included as it is part of the same vulnerable class and could be used post-exploitation.