Repository navigation
fix(auth): Better Auth 1.7 compatibility, auth hardening, dependency security updates - #15
Conversation
The 1.7.10 bump turned CI red and breaks auth at runtime. - Bump @better-auth/infra to 0.4.20. 0.2.x pinned @better-auth/utils 0.4 and pulled @better-auth/sso 1.6, so three copies of @better-auth/core were installed and dashClient no longer matched BetterAuthClientPlugin. That also dropped authClient.organization. - Move `experimental.joins` to `advanced.database.joins` (1.7 location). - Rename `sendResetPasswordEmail` to `sendResetPassword`. The old key was never a Better Auth option, so every password reset request failed with RESET_PASSWORD_DISABLED. - Add invitation.created_at (migration 0029). Better Auth 1.7 checks the schema before each auth request and rejects every request while the organization plugin's column is missing.
- Stop trusting https://*.vercel.app in Better Auth and the proxy. Anyone can deploy there, so it allowed redirects after OAuth sign-in and email verification to any Vercel site. With password reset working again, it would also have leaked reset tokens through `redirectTo`. Trusted origins now come from one module: exact origins only, this deployment's own Vercel URLs, and an optional BETTER_AUTH_TRUSTED_ORIGINS list. Loopback origins are dropped in production. - Keep Better Auth's built-in rate-limit counters in Upstash Redis through an atomic `consume`. The default in-memory storage counts per serverless instance. A Redis outage fails open, like the proxy. - Send auth emails through `advanced.backgroundTasks` and Next's `after`, so response timing does not reveal registered emails. - Revoke other sessions on password reset. Set explicit password bounds and secure cookies in production. - Make verification links last 24 hours, as the email promises. The default was 1 hour. - Send OAuth errors to /sign-in and show a fixed message there. - Remove the unused rateLimitUnavailable helper and correct SECURITY.md, which said rate limiting fails closed.
bun audit drops from 112 findings (6 critical) to 4 (none critical). - next 16.1.5 -> 16.3.8 (also brings patched sharp and postcss), with eslint-config-next to match - undici 6.21.3 -> 6.28.1 - vitest 3.2.4 -> 4.1.12 (critical UI-server file read; drops the vulnerable tinypool and fixes the @vitest/mocker path traversal) - ai and @ai-sdk/google within range (@ai-sdk/provider-utils) - in-range updates of ws, @xmldom/xmldom and other transitive packages The 4 remaining findings have no patched release and only run in tooling or unreachable paths: braces and esbuild (dev/build), sprintf-js (argparse help text via mammoth) and uuid (v4 only in svix).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The Better Auth 1.7.10 upgrade turned CI red on
mainand also breaks auth at runtime. This PR fixes both, hardens the auth configuration, and patches vulnerable dependencies. It has three commits, and each one passes lint, typecheck and tests on its own.1. Make the 1.7 upgrade build and run
@better-auth/infra0.2.14 → 0.4.20. 0.2.x pinned@better-auth/utils0.4 and pulled in@better-auth/sso1.6, which installed three copies of@better-auth/core.dashClientstopped matchingBetterAuthClientPlugin, andauthClient.organizationdisappeared from the client type.experimental.joinsmoves toadvanced.database.joins, its 1.7 location.sendResetPasswordEmail→sendResetPassword. The old key was never a Better Auth option, so every password reset request failed withRESET_PASSWORD_DISABLED.0029addsinvitation.created_at. Better Auth 1.7's organization plugin requires it, and the runtime schema check rejects auth requests without it. The migration is hand-written like 0012–0028 because the drizzle-kit snapshots stop at 0011.2. Harden the auth configuration
https://*.vercel.appis no longer trusted in Better Auth orproxy.ts. Anyone can deploy there. With the old config,callbackURLon/sign-in/socialand/send-verification-emailaccepted any*.vercel.appsite. With password reset working again,redirectTowould also have sent reset tokens to such a site.src/lib/trusted-origins.ts: exact origins only, this deployment's ownVERCEL_*URLs, and an optionalBETTER_AUTH_TRUSTED_ORIGINSlist.consume, instead of per-instance memory. If Redis is unreachable it fails open, the same policy as the proxy.advanced.backgroundTaskswith Next'safter), so response timing no longer reveals whether an email is registered./sign-in, which shows a fixed message. Theerror_descriptionquery value is not shown.rateLimitUnavailablehelper (the CI lint warning) and correctedSECURITY.md, which said rate limiting fails closed.3. Dependency security updates
bun auditgoes from 112 findings (6 critical) to 4 (none critical).next16.1.5 → 16.3.8, witheslint-config-nextto match. This also brings patchedsharpandpostcss.undici6.21.3 → 6.28.1.vitest3.2.4 → 4.1.12. This fixes the critical UI-server advisory, removestinypool, and fixes the@vitest/mockeradvisory.aiand@ai-sdk/googlewithin their ranges, plus in-range updates of transitive packages.The 4 remaining findings have no patched release and don't reach production code:
bracesandesbuildonly run in dev and build tooling.sprintf-jsis used forargparsehelp text viamammoth.uuidis only used for v4 insvix.Testing
checksjob locally: lint (0 warnings), typecheck, SDK typecheck, unit tests andnext buildall pass.migrationsjob on a fresh pgvector Postgres: migrations apply, the re-run is a no-op, and all 194 tests pass (including the DB integration tests).auth.handlerandproxy(NODE_ENV=production, real Postgres, real Redis behind the Upstash REST API):*.vercel.appredirectToorcallbackURLgets a 403. The old config accepted it.*.vercel.apporigin. The old config let it through.X-Retry-After.src/lib/__tests__/trusted-origins.test.ts.Before deploying
bun run db:migrateagainst production.UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKENare set.*.vercel.appURL other than this deployment's own, add it toBETTER_AUTH_TRUSTED_ORIGINS.