better-auth@1.6.35

The most comprehensive authentication framework for TypeScript.

  • latest version

    1.7.29

  • latest non vulnerable version

  • first published

    2 years ago

  • latest version published

    3 days ago

  • licenses detected

    • >=1.2.9-beta.9
  • Direct Vulnerabilities

    Known vulnerabilities in the better-auth package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • L
    Race Condition

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Race Condition via non-atomic secondary storage session list updates and cookie-cached session trust on sensitive routes. When secondaryStorage is in use, two concurrent session changes can cause a session to be dropped from the user's session list, allowing it to survive bulk revocation or a user ban. Additionally, when session.cookieCache is enabled, certain routes (passkey registration, device authorization, and passwordless two-factor enrollment) accept a revoked cached session to create a passkey or a new stored session that outlives the cache expiry, letting an attacker retain access after their session is revoked.

    Note: This is only exploitable if secondaryStorage is configured (for the bulk revocation bypass) or session.cookieCache is enabled alongside passkey registration, device authorization, or passwordless two-factor enrollment (for the cached session bypass).

    How to fix Race Condition?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    >=0.8.1-beta.5 <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • H
    Improper Authentication

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Improper Authentication in the phone number plugin, where sign-up and other flows save unverified phone numbers to an account, and phone OTP sign-in then selects the account solely by phone number without requiring phoneNumberVerified. An attacker can register an account and attach a victim's phone number to it before the victim does, so that when the victim later signs in with a valid OTP sent to their own phone, the session is issued for the attacker-controlled account, exposing data the victim subsequently enters. A secondary issue causes verification codes from different flows to share a namespace, allowing an attacker who can predict a pending code's record identifier to cancel it and block another user's sign-in or recovery attempt without gaining account access.

    How to fix Improper Authentication?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    >=0.4.12-beta.7 <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • H
    Improper Authentication

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Improper Authentication via email-change links that record the old and new addresses but not the requesting user's identity. When an attacker requests an email change away from their old address, and a victim later registers that released address while the link is still valid, the attacker opens the link and Better Auth resolves the account by looking up the current owner of the old address - creating a session for the victim's account and changing its email to one the attacker controls, resulting in a full account takeover.

    Note: This is only exploitable when user.changeEmail.enabled is turned on, emailVerification.sendVerificationEmail is configured, and a new user can register an address after its previous owner has moved to another one.

    How to fix Improper Authentication?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    >=1.4.0 <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • H
    Improper Authentication

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Improper Authentication via the OAuth sign-in flow, which treats unverified provider email addresses as verified. The flaw manifests in three ways: the string "false" for an email_verified claim is accepted as truthy; with genericOAuth(), the user info profile subject is not validated against the ID token subject, allowing a mismatched provider identity to be attached; and the Zoom provider ignores configured options such as disableSignUp and requireEmailVerification. An attacker who holds a victim's email address in an unverified state at an affected OAuth provider can sign in, be linked to the victim's existing local account, and obtain a valid session for that account.

    How to fix Improper Authentication?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    >=0.4.9 <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • H
    Race Condition

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Race Condition via a race condition in the MySQL/MariaDB serial ID retrieval path, where the inserted row's ID is read back using a separate LAST_INSERT_ID() query that may execute on a different pooled connection. Under concurrent load, a user signing in can receive another user's session token and act as that user, or a sign-up can return another user's record. The attacker cannot choose which account they receive.

    How to fix Race Condition?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • M
    Brute Force

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Brute Force via the emailOTP plugin, through three distinct weaknesses: a race condition in the attempt counter, collision-prone email change code keys, and accent-insensitive email lookups. The attempt counter is read and written in separate steps, so concurrent OTP guesses can each observe the same count, allowing an unauthenticated attacker to exceed allowedAttempts and brute-force an active OTP to sign in or reset a password. Email change codes are keyed on both addresses without binding to the requesting account, so two different address pairs can produce the same key and a code from one account can be consumed by another, allowing a signed-in user to verify an address they do not own. On databases that ignore accents, an email lookup can return an account whose stored address differs only by accented characters, causing password reset to deliver the code to the attacker's requested address rather than the account owner's, allowing an attacker who receives mail at an accent-variant address to reset the victim's password.

    Note: The email change code collision requires changeEmail.enabled: true in the plugin (available from 1.5.0); the accented address attack requires a database collation that ignores accents, common on MySQL.

    How to fix Brute Force?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    >=1.3.7 <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • H
    Incorrect Authorization

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Incorrect Authorization via the admin plugin's /admin/update-user endpoint, which checks user:set-email before allowing email changes but applies no equivalent guard to phoneNumber and phoneNumberVerified fields, requiring only the broader user:update permission. An attacker holding a limited role with user:update can overwrite a higher-privileged account's phone number and mark it as verified, then sign in to that account via phone OTP to obtain its session.

    Note: This is only exploitable when both the admin plugin and the phone number plugin are in use, and a role other than the full admin role holds the user:update permission.

    How to fix Incorrect Authorization?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • M
    Incorrect Behavior Order: Validate Before Canonicalize

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Incorrect Behavior Order: Validate Before Canonicalize via inconsistent whitespace handling in the organization plugin's invitation role validation. The creator role check compares the raw invitation role string, while later checks split and trim it. An admin or other non-creator role that can invite members can submit a padded role value such as " owner" that passes the creator role guard and resolves to owner upon acceptance, allowing the newly elevated account to delete the organization and remove the original owners.

    Note: This is only exploitable if a role other than the creator role (by default, owner) has permission to create invitations - with default roles, organization admins can.

    How to fix Incorrect Behavior Order: Validate Before Canonicalize?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    >=1.5.5 <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • C
    Origin Validation Error

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Origin Validation Error via the expo() plugin's public authorization-proxy endpoint, which signs a caller-supplied state value with the application secret without verifying that the server had previously issued that value. Because the same HMAC-SHA256 secret is used for email verification links and the session cookie cache, an attacker can forge an email-change token or a session cookie cache value that Better Auth accepts as legitimate. This allows an unauthenticated attacker who knows a target user's email address to take over the account and change its email address, and - when the session cookie cache is enabled - an attacker who knows a user's ID to act as that user.

    Note: The session cookie cache attack vector is only exploitable when the session cookie cache feature is explicitly enabled.

    How to fix Origin Validation Error?

    Upgrade better-auth to version 1.7.16, 1.8.0-beta.5 or higher.

    <1.7.16>=1.8.0-beta.0 <1.8.0-beta.5
    • C
    Improper Authentication

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Improper Authentication via insufficient isolation of verification records across different authentication flows. Because magic-link tokens and OAuth state tokens share the same verification storage namespace without purpose-binding, an attacker can substitute a verification record from one flow (e.g., an OAuth state token) in place of a magic-link token to satisfy the magic-link verification check, bypassing authentication and potentially gaining unauthorized account access.

    Note: This is only exploitable when OAuth state uses account.storeStateStrategy: "database", which is the default when a database or secondary storage is configured.

    How to fix Improper Authentication?

    Upgrade better-auth to version 1.7.7 or higher.

    >=1.4.0-beta.18 <1.7.7
    • C
    Improper Authentication

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Improper Authentication via insufficient isolation between verification record types, allowing an attacker to substitute a token issued for one authentication flow (e.g. an OAuth state token) in place of a magic-link verification token. Because verification records stored in the database share a common identifier namespace and the magic-link handler does not validate the type field of the retrieved record, an attacker who obtains a valid token from one flow can present it to a different flow's endpoint to authenticate as the token's associated email address without ever receiving a legitimate magic-link email.

    Note: This is only exploitable when OAuth state uses account.storeStateStrategy: "database", which is the default when a database or secondary storage is configured.

    How to fix Improper Authentication?

    Upgrade better-auth to version 1.7.7 or higher.

    >=1.4.0-beta.18 <1.7.7
    • C
    Improper Authentication

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Improper Authentication via cross-purpose reuse of verification records, where a token issued for one authentication flow (such as OAuth state or OAuth proxy) can be submitted to the magic-link verification endpoint to obtain a session. The magic-link handler previously looked up verification records by the raw stored token without a type discriminator, allowing an attacker who possesses a valid token from a different flow to authenticate as the associated user. The fix introduces purpose-scoped identifiers (prefixed with magic-link:) and a strict record schema check that rejects records not carrying type: "magic-link", and derives per-purpose encryption keys for OAuth flows using HKDF to prevent ciphertext reuse across contexts.

    How to fix Improper Authentication?

    Upgrade better-auth to version 1.7.7 or higher.

    >=1.5.0-beta.12 <1.7.7
    • M
    Brute Force

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to Brute Force via a race condition in the compare-and-swap UPDATE path in drizzle-adapter.ts and relations-v2/index.ts. Under PostgreSQL's READ COMMITTED isolation, the WHERE guard used to identify the target row was placed only in a subquery (id IN (targetIds)), which PostgreSQL does not re-evaluate after waiting on a concurrent writer. As a result, multiple concurrent UPDATE operations can all succeed once the first writer commits, allowing a second (or later) writer to overwrite a row even when the original guard condition is no longer satisfied. An attacker who can issue concurrent write requests can exploit this window to corrupt or overwrite record state they should not be able to modify.

    How to fix Brute Force?

    Upgrade better-auth to version 1.7.7 or higher.

    >=1.6.17 <1.7.7
    • H
    User Interface (UI) Misrepresentation of Critical Information

    better-auth is a The most comprehensive authentication library for TypeScript.

    Affected versions of this package are vulnerable to User Interface (UI) Misrepresentation of Critical Information via the deviceAuthorization plugin's GET /device endpoint, which omits the requesting client_id and scope from the approval page response. An attacker initiates a device authorization request via /device/code, then tricks a signed-in user into approving the code on an approval page that shows no client identity or requested permissions. Once approved, the attacker redeems the code at /device/token to obtain a live session token, gaining read and write access to any data the user's account can access.

    Note: This is only exploitable if the deviceAuthorization() plugin is explicitly enabled, an attacker can initiate a device request (i.e., validateClient is not configured or a valid public client is accessible), and the approval page does not independently surface server-checked client and scope information.

    Users are not affected if the opt-in deviceAuthorization() plugin is not enable.

    How to fix User Interface (UI) Misrepresentation of Critical Information?

    Upgrade better-auth to version 1.7.0-rc.3 or higher.

    >=1.3.8-beta.3 <1.7.0-rc.3