GHSA-8C5H-WX78-2CFG
@better-auth/sso: Unproven domain claims can allow account takeover or organization joins
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 1.4.8 | @better-auth/sso · -231 d desde divulgación | |
| Divulgación | Publicada | GHSA-8C5H-WX78-2CFG divulgada · CVSS 8.1 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Am I affected?
You may be affected if you use `@better-auth/sso` `1.4.9` through `1.6.26`, `1.7.0-beta.0` through `1.7.0-rc.4`, or a `1.4.8` beta, and untrusted users can set up SSO providers. You are affected if either setup matches:
- Verification off: you use the organization plugin, leave SSO organization provisioning enabled, and leave `domainVerification.enabled` unset or false. An untrusted user can create or administer an organization and register its SSO provider.
- Verification on: you set `domainVerification.enabled: true`. An untrusted user can both verify and update an SSO provider they own or administer. You allow implicit account linking, or you assign organizations by verified domain.
You are not affected if only trusted operators can register, update, or verify SSO providers. Exact ranges per setup are in Technical details.
Summary
The SSO plugin trusts a provider for the email domains it claims. Two flaws let a provider owner gain that trust for a domain they do not control. With verification off, organization assignment trusts unverified domains; with it on, a provider update during a verification check can mark an unproven domain as verified.
Impact
Verification off: an attacker who controls an organization gets users added to it with the default role. This happens when a user with a matching email domain later signs in with a social provider. The attacker cannot sign in as that user or access their account.
Verification on: a signed-in provider owner can link an identity provider they control to an existing user's account, with no action from the victim. The attacker gains that user's data and actions. Where organizations are assigned by verified domain, the attacker can also add matching users to their organization.
Patches
Upgrade `@better-auth/sso` to `1.6.27` on the stable line, or to `1.7.0-rc.5` on the `1.7` prerelease line.
Workarounds
If you cannot upgrade now, apply every step that matches your configuration:
- Stop untrusted users from registering, updating, or verifying SSO providers. Add your own authorization check before `/sso/register`, `/sso/update-provider`, and `/sso/verify-domain`.
- Set `account.accountLinking.disableImplicitLinking: true`. This blocks the account-takeover path.
- Set `organizationProvisioning.disabled: true`. This blocks automatic organization assignment.
- Review existing provider records. Remove domain claims from untrusted providers. Verify every domain again before you trust a provider that is already marked as verified.
Changing `domainVerification.enabled` alone does not fix both flaws. If you enable it, the domain-verification flaw is still reachable. If you disable it, the organization-assignment flaw is still reachable.
Technical details
Organization assignment trusts unverified domains. This flaw affects `@better-auth/sso` from `1.4.8-beta.1` up to, but not including, stable `1.4.8`; stable `1.4.9` through `1.6.25`; and `1.7.0-beta.0` through `1.7.0-rc.2`. It requires both the SSO and organization plugins, SSO organization provisioning left enabled, and `domainVerification.enabled` disabled or unset. An untrusted user must be able to create or administer an organization and register an SSO provider for it. A user whose email address is in the claimed domain must later sign in through a social-provider callback that the SSO plugin handles.
An organization owner or administrator can register an SSO provider with any domain. When domain verification is disabled, the organization-assignment lookup does not require that domain to be verified. After the social sign-in, the SSO plugin matches the user's email domain to that provider and adds the user to the attacker's organization with the default role. Control of a provider record is treated as control of the domain it claims. The attacker can see the user's organization-member identity, and the default member permissions apply to the user.
Domain verification can apply to the wrong domain. This flaw was introduced in `1.5.0-beta.10`. It affects stable releases through `1.6.26` and the `1.7` prerelease line through `1.7.0-rc.4`. It requires `domainVerification.enabled: true`. An untrusted authenticated user must own a personal SSO provider or administer an organization-scoped provider, and must be able to reach both `/sso/verify-domain` and `/sso/update-provider`. The application must allow implicit account linking, or use verified SSO domains for automatic organization assignment. Implicit account linking means Better Auth connects a new sign-in to an existing account that has the same email address.
The verification endpoint reads the provider and its domains before it starts asynchronous DNS (Domain Name System) lookups. While the lookups are pending, the provider-update endpoint can change the domains and reset `domainVerified` to false. When the original lookup succeeds, verification matches the provider only by `providerId` and sets `domainVerified: true`. It never checks that the current domains passed the DNS check. The provider then carries a verified mark for a domain the owner never proved.
OpenID Connect (OIDC) and Security Assertion Markup Language (SAML) callbacks trust a provider when `domainVerified` is true and the asserted email matches its stored domain. An identity provider controlled by the attacker can therefore assert an existing user's email and reach implicit account linking. Applications that use verified domains for organization assignment can also add matching users to the attacker's organization.
The fix. The patched releases enforce both domain-trust boundaries:
- Domain verification binds the final write to the same provider row, the exact stored domains that passed DNS verification, and a provider that is still unverified. If the provider changes during verification, verification fails and applies no stale proof.
- Automatic organization assignment requires domain verification to be enabled. It also requires a verified provider domain, a verified stored user email, normalized domain matching, and exactly one matching organization.
References
- CWE-287: Improper Authentication
https://cwe.mitre.org/data/definitions/287.html - CWE-345: Insufficient Verification of Data Authenticity
https://cwe.mitre.org/data/definitions/345.html - CWE-367: Time-of-check Time-of-use Race Condition
https://cwe.mitre.org/data/definitions/367.html - CWE-862: Missing Authorization
https://cwe.mitre.org/data/definitions/862.html - Affected domain-verification route
https://github.com/better-auth/better-auth/blob/ea38fcac7435137604e9b3ba2fe149a1848d0eeb/packages/sso/src/routes/domain-verification.ts - Affected organization-assignment helper
https://github.com/better-auth/better-auth/blob/ea38fcac7435137604e9b3ba2fe149a1848d0eeb/packages/sso/src/linking/org-assignment.ts#L87-L175 - Affected SSO callback hook
https://github.com/better-auth/better-auth/blob/ea38fcac7435137604e9b3ba2fe149a1848d0eeb/packages/sso/src/index.ts#L236-L258
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@better-auth/sso |
Corregida | 1.4.8 | -231 d | 1.7.25 no afectada |
1.4.8Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/better-auth/better-auth/security/advisories/GHSA-8c5h-wx78-2cfgLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
