The vulnerability, GHSA-g2pf-ww5m-2r9m, stems from a failure to enforce organization-specific scopes (urn:zitadel:iam:org:id:{id} and urn:zitadel:iam:org:domain:primary:{domainname}) across various authentication flows in Zitadel. This allowed a user belonging to one organization to authenticate into an application that should have been restricted to a different organization.
The analysis of the patch commit d90285929ca019fa817f31551fd0883429dda2a8 reveals that the issue was addressed by adding checks at multiple layers of the authentication and authorization process.
-
Auth Request Creation: The function createAuthRequestScopeAndAudience in internal/api/oidc/auth_request.go was modified to validate and extract the organization ID from the scopes. Previously, it ignored these scopes, creating a loophole where the organization context was lost at the beginning of the flow.
-
Session and Device Flow Enforcement: The core logic in the internal/command package was updated. Functions like LinkSessionToAuthRequest, ApproveDeviceAuth, and ApproveDeviceAuthWithSession now explicitly check if the user's organization matches the organization ID stored in the authentication or device authorization request. Before the patch, these checks were missing, allowing a session from any organization to be used.
-
Frontend UI: In the Login V2 application, the TypeScript functions loadSessions and findValidSession were updated to filter a user's sessions based on the required organization. This prevents a user from selecting or being automatically logged in with a session associated with an incorrect organization.
In summary, the exploitation of this vulnerability would involve functions responsible for creating authentication requests, linking user sessions, and handling device authorization approvals. The identified vulnerable functions are the points where the organization scope was not being enforced, allowing the bypass.