[PR #6142] [MERGED] fix(email-otp): use constant time equal for equality checks #23378

Closed
opened 2026-04-15 21:40:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6142
Author: @Bekacru
Created: 11/20/2025
Status: Merged
Merged: 11/22/2025
Merged by: @Bekacru

Base: canaryHead: reafactor/email-otp


📝 Commits (10+)

📊 Changes

4 files changed (+100 additions, -61 deletions)

View changed files

📝 docs/content/docs/plugins/email-otp.mdx (+4 -0)
📝 packages/better-auth/src/crypto/buffer.ts (+8 -2)
📝 packages/better-auth/src/plugins/email-otp/email-otp.test.ts (+4 -6)
📝 packages/better-auth/src/plugins/email-otp/index.ts (+84 -53)

📄 Description

Summary by cubic

Use constant-time comparison for all OTP checks to prevent timing attacks; constantTimeEqual now supports strings and replaces direct equality across encrypted, hashed, and custom flows. Strengthen email OTP to prevent user enumeration: return success without sending when the email has no account, only surface user-not-found during OTP verification, and optionally revoke sessions on reset.

Written for commit e552a6fd87. 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/6142 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 11/20/2025 **Status:** ✅ Merged **Merged:** 11/22/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `reafactor/email-otp` --- ### 📝 Commits (10+) - [`fdf9266`](https://github.com/better-auth/better-auth/commit/fdf92663bb23bbf842af735b7dd8af62163f9c8e) update - [`dbd1eb8`](https://github.com/better-auth/better-auth/commit/dbd1eb86779922f02ff9153af5fe0b69ddc875f7) improvements - [`75ba55c`](https://github.com/better-auth/better-auth/commit/75ba55c2ba8c722b0cfed4dc33ee18f1df2ecb13) update - [`c8ffdb9`](https://github.com/better-auth/better-auth/commit/c8ffdb971a7cf3e9342371a79a93e89b06698aac) remove account - [`029aee3`](https://github.com/better-auth/better-auth/commit/029aee3d7ed6d9405c402c3a3b0257127b92cdce) remove - [`3dd1a77`](https://github.com/better-auth/better-auth/commit/3dd1a77faf101636b9c075e76e374e87c5d03f94) add doc - [`5684fb1`](https://github.com/better-auth/better-auth/commit/5684fb12827fadddc013d01f2c0128bcabe4bcff) warn - [`2f8fcec`](https://github.com/better-auth/better-auth/commit/2f8fcecf4745a7d0003dc051ae72deadd3936387) cleanup - [`27242e5`](https://github.com/better-auth/better-auth/commit/27242e525c90986e439a2cc5300d4123d3fb8336) fix test - [`8785875`](https://github.com/better-auth/better-auth/commit/8785875b18afb7fc56e2e20b489687f0edddf192) fix ### 📊 Changes **4 files changed** (+100 additions, -61 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/email-otp.mdx` (+4 -0) 📝 `packages/better-auth/src/crypto/buffer.ts` (+8 -2) 📝 `packages/better-auth/src/plugins/email-otp/email-otp.test.ts` (+4 -6) 📝 `packages/better-auth/src/plugins/email-otp/index.ts` (+84 -53) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Use constant-time comparison for all OTP checks to prevent timing attacks; constantTimeEqual now supports strings and replaces direct equality across encrypted, hashed, and custom flows. Strengthen email OTP to prevent user enumeration: return success without sending when the email has no account, only surface user-not-found during OTP verification, and optionally revoke sessions on reset. <sup>Written for commit e552a6fd87418219b25d055e892d2ea4b026dbe1. 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-15 21:40:39 -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#23378