Summary
A broken access control issue in the Better Auth SSO plugin allows any organization member to register new SSO providers via the /sso/register endpoint without requiring owner or admin privileges.
If an attacker-controlled OIDC or SAML provider is attached, its /sso/callback/{providerId} flow can be abused to influence organization provisioning and membership, potentially escalating privileges or onboarding unauthorized identities.
Affected context
The vulnerability affects applications using the @better-auth/sso plugin for TypeScript-based Better Auth deployments between versions 1.2.10 and 1.6.11.
It arises in multi-user organizations where the /sso/register endpoint is exposed to logged-in members and the system treats SSO configuration as an administrative operation.
Environments that rely on OIDC or SAML integration for automated provisioning and sign-in are particularly exposed, as SSO provider configuration directly drives identity onboarding.
Exploit preconditions
- Attack surface: Application backend endpoint
POST /sso/registerexposed via Better Auth SSO integration - Required access: Authenticated membership in the target organization (not necessarily admin or owner)
- Trigger point: Sending a crafted registration request to attach an attacker-controlled OIDC or SAML provider to the organization
- Why exploitation is possible: The
registerSSOProviderlogic checks only for an organization membership record and does not enforce role-based authorization, allowing non-privileged users to perform administrative SSO configuration actions
Why this happens
The core issue is an authorization design flaw where a sensitive administrative operation—registering SSO providers for an organization—is gated solely by membership, not by appropriate roles or privileges.
This maps to CWE-269: Improper Privilege Management and CWE-285: Improper Authorization, where operations that should be restricted to high-privilege users are available to any authenticated member.
Conceptually, the code treats "is user in organization?" as sufficient to perform configuration changes, rather than enforcing a stricter policy such as "is organization owner or admin?" for SSO provider registration.
Potential impact
- An attacker who is a regular organization member may register an attacker-controlled OIDC or SAML provider.
- The attacker-controlled SSO provider could be used to onboard arbitrary accounts into the organization.
- Organization provisioning flows may be manipulated, potentially granting broader access than intended.
- SSO trust relationships can be subverted, undermining the integrity of identity and access management.
- Auditability and accountability of organization membership may be degraded due to uncontrolled SSO configuration.
General mitigation guidance
Effective mitigation focuses on enforcing strict authorization boundaries around SSO configuration and other administrative actions.
Common defensive patterns include:
- Applying role-based access control (RBAC) checks to all endpoints that modify authentication, SSO, or organization-level settings, ensuring only owners or admins can register or modify SSO providers.
- Centralizing authorization decisions so that sensitive operations consistently use well-defined policies instead of ad hoc membership checks.
- Treating identity provider and SSO configuration as high-trust operations that require explicit elevation (e.g., admin-only routes or step-up authentication).
- Logging and monitoring changes to SSO configuration, and limiting which roles are allowed to manage identity provider settings.
- Designing APIs so that organization-wide security settings are never modifiable by users with default or minimal roles.
How teams detect issues like this
Detection typically involves a mix of code-level and behavioral analysis:
- Static analysis and code review: Search for routes and handlers that change organization or SSO configuration and verify they enforce role checks beyond simple membership. Look for patterns like
if (isMember)without further privilege validation. - Authorization policy validation: Maintain a mapping of high-risk actions (e.g., SSO registration, identity provider changes, organization-wide settings) and ensure tests assert that only privileged roles can invoke them.
- Runtime monitoring: Instrument logging around
/sso/registerand related endpoints to detect unusual patterns, such as non-admin users registering new SSO providers or sudden spikes in provider changes. - Automated security testing: Use integration tests or security scanners that simulate lower-privilege users attempting to access administrative endpoints to catch regression in access control logic.

