Account Takeover and Stale Access via SCIM Provider-ID Collision in @better-auth/scim
The `@better-auth/scim` package is affected by multiple vulnerabilities, including a critical provider-ID collision flaw that allows authenticated users to craft SCIM tokens impersonating existing account providers, leading to unauthorized account access, profile modification, and user deletion, while additional issues include failed user deactivation and email update vulnerabilities bypassing uniqueness checks in versions `1.4.0-beta.27` through `1.6.21` and `1.7.0-beta.0` through `1.7.0-beta.9`.
The @better-auth/scim plugin, utilized by applications registering it, is critically vulnerable to multiple flaws, including a provider-ID collision issue (GHSA-rjg6-39jm-rgg4). This vulnerability, affecting versions from 1.4.0-beta.27 through 1.6.21 and 1.7.0-beta.0 through 1.7.0-beta.9, allows an authenticated attacker to craft SCIM tokens whose providerId matches an existing SSO, SAML, OIDC, or social provider. This enables unauthorized account access, modification of profile fields, and complete deletion of user accounts not managed by the SCIM token. Additionally, the plugin fails to correctly process active: false deactivation requests, potentially leaving terminated users with continued access, and bypasses email uniqueness checks during updates, leading to data corruption. These issues could lead to significant security breaches, including widespread account takeovers and denial of service for legitimate users.
Attack Chain
- An authenticated user accesses an application integrated with
@better-auth/scimand generates a SCIM bearer token, leveraging either the defaultcanGenerateTokenpolicy or a custom policy vulnerable toproviderIdcollision. - The attacker identifies a legitimate
providerId(e.g., from an SSO, SAML, OIDC, or social provider) already in use by other account rows within the application's database. - The attacker crafts the SCIM bearer token or modifies its
providerIdto explicitly collide with this identified legitimateproviderId. - Using this maliciously crafted SCIM token, the attacker sends a
DELETE /scim/v2/Users/:idAPI request to the application, targeting a specific user ID. - The
@better-auth/scimplugin, due to theproviderIdcollision, incorrectly maps the request to a global user account associated with the legitimate, colliding provider, even if the SCIM token never provisioned that user. - The application proceeds to delete the global user and their associated sessions, leading to unauthorized account access removal and denial of service for the legitimate user.
- Alternatively, the attacker could use
PUTorPATCHrequests with the crafted token to rewrite global profile fields for SSO-provisioned organization members by leveraging theproviderIdcollision. - Further exploitation includes leveraging the absence of email uniqueness checks in
PUTorPATCHupdates to assign one user's email to another, potentially corrupting user login and lookup capabilities.
Impact
The provider-ID collision issue allows an authenticated attacker to gain unauthorized access to and manipulate user accounts not under the SCIM token's legitimate scope. Attackers can delete global user records, modify profile information for SSO-provisioned organization members, and potentially corrupt email-keyed login data by reassigning email addresses without uniqueness checks. The deactivation flaw means terminated users might retain access, as the active: false attribute is ignored, allowing continued presence in the system even after an identity provider signals deprovisioning. These vulnerabilities pose a critical risk of widespread account takeover, denial of service, and data integrity issues for affected applications.
Recommendation
- Immediately upgrade
@better-auth/scimto version1.6.22or1.7.0-beta.10to address theproviderIdcollision, deactivation, and email update vulnerabilities. - If immediate upgrade is not possible, configure the
canGenerateTokenpolicy to explicitly rejectproviderIdvalues that match any existing built-in, social, generic OAuth, SSO, SAML, or OIDC account provider IDs in your application. - Restrict the generation of SCIM tokens to only trusted, privileged users to limit exposure to these vulnerabilities.
- Audit existing
scimProviderrows in your application and remove any rows whoseproviderIdmatches another existing account provider namespace. - Avoid relying solely on deactivation reports from your identity provider; manually confirm that deactivated users have lost access, particularly if your identity provider uses
active: falsefor deprovisioning.