[PR #6342] [MERGED] fix(multi-session): Endpoints breaks with invalid signatures #14851

Closed
opened 2026-04-13 09:39:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6342
Author: @ping-maxwell
Created: 11/27/2025
Status: Merged
Merged: 11/27/2025
Merged by: @Bekacru

Base: canaryHead: fix/multi-session-breaking-due-to-invalid-sig


📝 Commits (1)

  • 9a73552 fix(multi-session): listDeviceSession and other endpoints breaks with invalid past signatures

📊 Changes

1 file changed (+3 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/plugins/multi-session/index.ts (+3 -4)

📄 Description

Say you use a BETTER_AUTH_SECRET of 1 and signed in, then the next day you changed it to 2, this would cause the multi-session plugin to crash in various places.

This is because ctx.getSignedCookie returns false when a cookie has an invalid signature, however due to Better-Call having the incorrect types it caused us to develop Multi-Session incorrectly without considering the possibility that getSignedCookie can return false, thus breaking the plugin.

Better-Call fix to the type issue:
https://github.com/Bekacru/better-call/pull/81


Summary by cubic

Prevented multi-session endpoints from crashing when cookie signatures are invalid (e.g., after rotating BETTER_AUTH_SECRET). We now handle getSignedCookie returning non-string values safely.

  • Bug Fixes
    • Filtered cookie results to only keep string tokens across list and delete session paths.
    • Added safe early returns when no valid session tokens are found.

Written for commit 9a73552783. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6342 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 11/27/2025 **Status:** ✅ Merged **Merged:** 11/27/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/multi-session-breaking-due-to-invalid-sig` --- ### 📝 Commits (1) - [`9a73552`](https://github.com/better-auth/better-auth/commit/9a73552783da1e01363730f281f4483c62b3c0d9) fix(multi-session): listDeviceSession and other endpoints breaks with invalid past signatures ### 📊 Changes **1 file changed** (+3 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/multi-session/index.ts` (+3 -4) </details> ### 📄 Description Say you use a BETTER_AUTH_SECRET of `1` and signed in, then the next day you changed it to `2`, this would cause the multi-session plugin to crash in various places. This is because `ctx.getSignedCookie` returns `false` when a cookie has an invalid signature, however due to Better-Call having the incorrect types it caused us to develop Multi-Session incorrectly without considering the possibility that `getSignedCookie` can return false, thus breaking the plugin. Better-Call fix to the type issue: https://github.com/Bekacru/better-call/pull/81 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevented multi-session endpoints from crashing when cookie signatures are invalid (e.g., after rotating BETTER_AUTH_SECRET). We now handle getSignedCookie returning non-string values safely. - **Bug Fixes** - Filtered cookie results to only keep string tokens across list and delete session paths. - Added safe early returns when no valid session tokens are found. <sup>Written for commit 9a73552783da1e01363730f281f4483c62b3c0d9. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:39:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14851