REDHAT-BUG-2529289: High severity Foreman Foreman vulnerability
Foreman contains an authorization flaw in the Foreman::Controller::UserAware#finduser handling used by Api::V2::PersonalAccessTokensController. The controller resolves the target account directly with User.find(params[:userid]) without enforcing the parent-user authorization that normally restricts access to the target user. As a result, a user who has the createpersonalaccesstokens permission can create a Personal Access Token for another user whose account is accessible by ID within the user's taxonomy scope.
The vulnerable endpoint is POST /api/v2/users/:userid/personalaccesstokens. During token creation, the controller builds the Personal Access Token from the attacker-supplied userid and returns the plaintext token value in the API response.
The PersonalAccessToken#checkpermissionsaftersave model validation does not prevent this cross-user operation: when the token belongs to another user, it verifies the createpersonalaccesstokens permission on the token itself but does not require editusers authorization on the target user.
An attacker with the required createpersonalaccesstokens permission can therefore forge a valid PAT belonging to another user and subsequently authenticate as that user using the generated token. This can result in complete account takeover, including takeover of administrator accounts that are visible within the attacker's taxonomy scope.