fix(security): upgrade better-auth to 1.7.14 #75
Loading…
Reference in a new issue
No description provided.
Delete branch "security/better-auth-1.7"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changed
better-auth,@better-auth/passkeyand@better-auth/expo: 1.6.33 -> 1.7.14 (latest 1.7.x), bumped in lockstep. The lockfile now has a single 1.7.14 for every@better-auth/*package.@thallesp/nestjs-better-auth2.6.0 already acceptsbetter-auth >=1.5.0 <2.0.0.drizzle/0031_two_factor_lockout.sql(generated withpnpm drizzle-kit generate), with the matching columns insrc/db/auth-schema.ts:src/auth.tsbuilds without edits.Base is
main, the branch Coolify deploys, same as #74.developis currently one commit behindmain(the #74 merge), so it needs a sync after this lands.package.jsonversion is unchanged (non-develop PR rule). Bump it before merging if you want av1.1.3release.Advisories fixed
We don't use magic link, OAuth proxy or device authorization, so the critical and high findings were not reachable in our config. Grype flags the package version regardless, so the upgrade clears the image scan.
pnpm audit --prod: before, 6 findings (1 critical, 2 high, 3 low, all better-auth). After: No known vulnerabilities found.Why the migration is required
The twoFactor plugin added account-lockout columns (
failedVerificationCount,lockedUntil) in late 1.6. I checked the published tarballs: they are absent in 1.6.20 and present from 1.6.25. Our Drizzle schema never got them. 1.7.3+ checks the Drizzle schema at boot and rejects every auth request on a mismatch, in every environment. I ranauth-email-password.int-spec.tswithout the schema change and all 6 tests failed, with:Both columns are nullable or defaulted, so the migration is additive and safe on a live table.
main.tsapplies it on boot, before Better-Auth handles requests.There is no other schema change between 1.6.33 and 1.7.14 for what we use (core, username, twoFactor, passkey, bearer, expo). I dumped
getAuthTables()for our plugin set under both versions and the field sets are identical, which means the lockout columns were already expected by 1.6.33. The 1.7.0account.issuercolumn and its backfill were reverted in 1.7.3, and the upgrade guide confirms the account schema is unchanged from 1.6.drizzle-kit generateproduced only the two statements above, so there is no other drift.Side note: since #74 (1.6.12 -> 1.6.33), production has been running a twoFactor plugin that writes these two columns without them in the schema. I haven't checked whether 2FA verification fails today, but it's worth a look in the prod logs.
Other 1.7 changes reviewed (no action needed)
enableTwoFactornow returns amethodfield. It defaults to"totp"and still returnstotpURI/backupCodes. The front callstwoFactor.enable({ password })and readstotpURI, so it keeps working.Hostwith a dynamicbaseURL: ourbaseURLis static (BETTER_AUTH_URL).session_tokencookie. Existing sessions should survive, but some users may get signed out once.rollnote-appstays on its 1.6.11 client, which talks to a 1.7 server fine.Tests
pnpm install --frozen-lockfile: okpnpm lint: okpnpm exec tsc --noEmit -p tsconfig.json: okpnpm build: okpnpm openapi:generate: no drift inopenapi.jsonpnpm test(unit): 31 suites, 302 tests passedpnpm test:int(testcontainers on rootless podman, Postgres 18 + Mailpit, all migrations including 0031): 34 suites, 333 tests passed.pnpmfile.cjsstill keeps drizzle-kit, tsx and esbuild out of the prod dependency tree (pnpm ls --prodfinds none).I didn't run the Docker image build or a Grype scan locally. CI runs the Docker build.
To check after deploy
[Better Auth]: Drizzle schema mismatchline.