[PR #5057] [CLOSED] feat: implement timing attack protection for authentication endpoints #5745

Closed
opened 2026-03-13 12:34:04 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5057
Author: @himself65
Created: 10/2/2025
Status: Closed

Base: canaryHead: himself65/2025/10/02/auth


📝 Commits (1)

  • 14d052a feat: implement timing attack protection for authentication endpoints

📊 Changes

4 files changed (+114 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.test.ts (+41 -0)
📝 packages/better-auth/src/api/to-auth-endpoints.ts (+38 -0)
packages/better-auth/src/context/timing.ts (+22 -0)
📝 packages/better-auth/src/types/options.ts (+13 -0)

📄 Description

Summary by cubic

Adds timing attack protection to auth endpoints by delaying fast error responses to match the average success time per endpoint. Enabled by default via advanced.enableTimingProtection to reduce information leaks during auth flows.

  • New Features
    • Track per-endpoint successful execution time using a moving average (per auth instance via WeakMap).
    • Delay error responses when they are faster than the tracked average for that endpoint.
    • New advanced.enableTimingProtection option (default true) to allow opting out.

🔄 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/5057 **Author:** [@himself65](https://github.com/himself65) **Created:** 10/2/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `himself65/2025/10/02/auth` --- ### 📝 Commits (1) - [`14d052a`](https://github.com/better-auth/better-auth/commit/14d052ad675b6382b277a8b1f04503c96d0daea8) feat: implement timing attack protection for authentication endpoints ### 📊 Changes **4 files changed** (+114 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.test.ts` (+41 -0) 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+38 -0) ➕ `packages/better-auth/src/context/timing.ts` (+22 -0) 📝 `packages/better-auth/src/types/options.ts` (+13 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds timing attack protection to auth endpoints by delaying fast error responses to match the average success time per endpoint. Enabled by default via advanced.enableTimingProtection to reduce information leaks during auth flows. - **New Features** - Track per-endpoint successful execution time using a moving average (per auth instance via WeakMap). - Delay error responses when they are faster than the tracked average for that endpoint. - New advanced.enableTimingProtection option (default true) to allow opting out. <!-- 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-03-13 12:34:04 -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#5745