[PR #6194] Fix: delete passkey verification challenge after successful verification #6513

Open
opened 2026-03-13 13:01:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6194
Author: @Ridhim-RR
Created: 11/22/2025
Status: 🔄 Open

Base: canaryHead: fix/passkey/delete-challenge


📝 Commits (6)

📊 Changes

1 file changed (+28 additions, -0 deletions)

View changed files

📝 packages/passkey/src/index.ts (+28 -0)

📄 Description

Closes #6192

Summary
This PR updates two key functions, verifyPasskeyRegistration and verifyPasskeyAuthentication, to delete the verification challenge rows from the database after successful passkey registration or authentication. It also clears the challenge cookie to prevent reuse or replay attacks. This improves security by enforcing single-use challenges and keeps the verification store clean.

Changes Made

  • Added logic to delete verification challenge rows after successful registration or authentication.
  • Clear the challenge cookie at the same point.

Summary by cubic

Deletes WebAuthn verification challenges and clears the passkey cookie after successful registration or authentication. This enforces single-use challenges, prevents replay attacks, and keeps the verification store clean.

  • Bug Fixes
    • Remove verification rows on success using internalAdapter.deleteVerificationValue.
    • Clear the WebAuthn challenge cookie (maxAge=0) to block reuse.
    • Add tests confirming challenge deletion, cookie clearing, and session cookie set on authentication.

Written for commit 642db75b74. 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/6194 **Author:** [@Ridhim-RR](https://github.com/Ridhim-RR) **Created:** 11/22/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `fix/passkey/delete-challenge` --- ### 📝 Commits (6) - [`6afd4dd`](https://github.com/better-auth/better-auth/commit/6afd4dd77a71a3b27262a5193b256b9167ceac11) fix(Passkey):delete-challenge - [`034f757`](https://github.com/better-auth/better-auth/commit/034f757adc245f05e20f1e79eaf72c596f5191b1) fix: test case - [`b5b22f3`](https://github.com/better-auth/better-auth/commit/b5b22f3e464161df51286113bf16d5ee92782eb0) Merge branch 'canary' into fix/passkey/delete-challenge - [`4a50afa`](https://github.com/better-auth/better-auth/commit/4a50afa365e1900b6429c814856eb6ccaa4d361e) chore: lint issue - [`93187d7`](https://github.com/better-auth/better-auth/commit/93187d726e1950789e5aacaa48777a2fc2578b78) Merge branch 'canary' of https://github.com/Ridhim-RR/better-auth into fix/passkey/delete-challenge - [`642db75`](https://github.com/better-auth/better-auth/commit/642db75b743607ced6b2c995d1f836ee348db5a3) Merge branch 'fix/passkey/delete-challenge' of https://github.com/Ridhim-RR/better-auth into fix/passkey/delete-challenge ### 📊 Changes **1 file changed** (+28 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/passkey/src/index.ts` (+28 -0) </details> ### 📄 Description Closes #6192 **Summary** This PR updates two key functions, verifyPasskeyRegistration and verifyPasskeyAuthentication, to delete the verification challenge rows from the database after successful passkey registration or authentication. It also clears the challenge cookie to prevent reuse or replay attacks. This improves security by enforcing single-use challenges and keeps the verification store clean. **Changes Made** - Added logic to delete verification challenge rows after successful registration or authentication. - Clear the challenge cookie at the same point. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Deletes WebAuthn verification challenges and clears the passkey cookie after successful registration or authentication. This enforces single-use challenges, prevents replay attacks, and keeps the verification store clean. - **Bug Fixes** - Remove verification rows on success using internalAdapter.deleteVerificationValue. - Clear the WebAuthn challenge cookie (maxAge=0) to block reuse. - Add tests confirming challenge deletion, cookie clearing, and session cookie set on authentication. <sup>Written for commit 642db75b743607ced6b2c995d1f836ee348db5a3. 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-03-13 13:01:48 -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#6513