The vulnerability analysis identified two key functions in coderd/userauth.go that were responsible for the OIDC account takeover vulnerability.
The first vulnerable function, findLinkedUser, allowed an attacker to link their OIDC account to a victim's Coder account by exploiting the email-based user matching fallback. The function would first attempt to find a user by their linked_id, but if that failed, it would fall back to searching by email. An attacker could abuse this by creating an OIDC account with the same email as the victim. The patch mitigates this by restricting the email fallback to only first-time account linking and legacy accounts, preventing an existing account from being linked to a new OIDC subject.
The second vulnerable function, API.userOIDC, improperly validated the email_verified claim. The original implementation only checked for a boolean false value, treating any other value or an absent claim as verified. This allowed an attacker to bypass email verification. The patch introduces a new function, coerceEmailVerified, which correctly handles various data types for the email_verified claim and defaults to false (unverified) if the claim is missing or in an unexpected format.
By analyzing the provided patches, it was possible to pinpoint these two functions as the root cause of the vulnerability. The identified functions would be present in runtime profiles during an exploitation attempt, making them critical indicators for detecting and responding to this vulnerability.