The vulnerability lies in the improper validation of JSON Web Tokens (JWTs) used for organization invitations in Keycloak. The root cause is the org.keycloak.organization.utils.Organizations.parseInvitationToken function, which decoded the JWT without verifying its cryptographic signature. This allowed an attacker to take a legitimate invitation token, modify its payload to change the target organization ID and email, and use this tampered token to register a new user into an organization of their choice.
The vulnerable parseInvitationToken function was called from multiple places within the registration flow, including RegistrationPage.render (when the registration page is displayed) and RegistrationUserCreation.validateOrganizationInvitation (when the user is being created). The LoginActionsService.registerRequest method, which controls the registration flow, was also modified to ensure that token validation happens before any registration actions are taken.
The patch addresses this vulnerability by replacing the insecure token parsing with a new implementation that performs proper signature verification using SignatureVerifierContext. This ensures that any tampered tokens are detected and rejected, preventing unauthorized access.