fix(passkey): use data.id instead of challengeId in deleteVerificationValue calls #2553

Closed
opened 2026-03-13 10:02:43 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @nilskroe on GitHub (Dec 17, 2025).

Bug Description

The passkey plugin's verifyPasskeyRegistration and verifyPasskeyAuthentication endpoints incorrectly pass challengeId to deleteVerificationValue() instead of data.id.

Root Cause

In packages/passkey/src/routes.ts:

  1. verifyPasskeyRegistration (line ~340):
const data = await ctx.context.internalAdapter.findVerificationValue(challengeId);
// ... later ...
await ctx.context.internalAdapter.deleteVerificationValue(challengeId); // ❌ Wrong

2. verifyPasskeyAuthentication (line ~424):
const data = await ctx.context.internalAdapter.findVerificationValue(challengeId);
// ... later ...
await ctx.context.internalAdapter.deleteVerificationValue(challengeId); // ❌ Wrong

The challengeId is a 32-character random string generated by generateId(32) and stored as the identifier field in the verification table. However, deleteVerificationValue() expects the document's id field, not the identifier.

Impact

This bug breaks passkey authentication with database adapters that:
- Use the id field to look up documents for deletion (e.g., Convex adapter)
- Have strict ID validation (e.g., Convex requires base32-encoded IDs)

Error seen with Convex adapter:
Invalid argument 'id' for 'db.get': Unable to decode ID: ID wasn't valid base32

Fix

Change both occurrences from:
await ctx.context.internalAdapter.deleteVerificationValue(challengeId);

To:
await ctx.context.internalAdapter.deleteVerificationValue(data.id);

Affected Version

@better-auth/passkey@1.4.7

Workaround

Apply a patch to node_modules/@better-auth/passkey/dist/index.mjs using your package manager's patch feature (e.g., bun patch, pnpm patch, yarn patch).
Originally created by @nilskroe on GitHub (Dec 17, 2025). ## Bug Description The passkey plugin's `verifyPasskeyRegistration` and `verifyPasskeyAuthentication` endpoints incorrectly pass `challengeId` to `deleteVerificationValue()` instead of `data.id`. ## Root Cause In `packages/passkey/src/routes.ts`: 1. **verifyPasskeyRegistration** (line ~340): ```typescript const data = await ctx.context.internalAdapter.findVerificationValue(challengeId); // ... later ... await ctx.context.internalAdapter.deleteVerificationValue(challengeId); // ❌ Wrong 2. verifyPasskeyAuthentication (line ~424): const data = await ctx.context.internalAdapter.findVerificationValue(challengeId); // ... later ... await ctx.context.internalAdapter.deleteVerificationValue(challengeId); // ❌ Wrong The challengeId is a 32-character random string generated by generateId(32) and stored as the identifier field in the verification table. However, deleteVerificationValue() expects the document's id field, not the identifier. Impact This bug breaks passkey authentication with database adapters that: - Use the id field to look up documents for deletion (e.g., Convex adapter) - Have strict ID validation (e.g., Convex requires base32-encoded IDs) Error seen with Convex adapter: Invalid argument 'id' for 'db.get': Unable to decode ID: ID wasn't valid base32 Fix Change both occurrences from: await ctx.context.internalAdapter.deleteVerificationValue(challengeId); To: await ctx.context.internalAdapter.deleteVerificationValue(data.id); Affected Version @better-auth/passkey@1.4.7 Workaround Apply a patch to node_modules/@better-auth/passkey/dist/index.mjs using your package manager's patch feature (e.g., bun patch, pnpm patch, yarn patch).
GiteaMirror added the bug label 2026-03-13 10:02:43 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 17, 2025):

(tag @better-auth-agent if you would like an answer from the Agent)

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 17, 2025): (tag @better-auth-agent if you would like an answer from the Agent) _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@nilskroe commented on GitHub (Dec 17, 2025):

@better-auth-agent

@nilskroe commented on GitHub (Dec 17, 2025): @better-auth-agent
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 17, 2025):

Thanks for reporting this bug with the passkey plugin. The issue occurs because the endpoints use the challengeId when calling deleteVerificationValue, but the function actually expects the document’s id (data.id). To resolve the problem, update the code in both the verifyPasskeyRegistration and verifyPasskeyAuthentication endpoints so that deleteVerificationValue is called with data.id instead of challengeId. As a workaround, you can patch your local installation (e.g., using yarn patch, pnpm patch, or bun patch) until a new release is available that incorporates this fix.

Could you let me know if you’re seeing any other issues with your adapter, or if there’s anything else I can help clarify? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 17, 2025): Thanks for reporting this bug with the passkey plugin. The issue occurs because the endpoints use the challengeId when calling deleteVerificationValue, but the function actually expects the document’s id (data.id). To resolve the problem, update the code in both the verifyPasskeyRegistration and verifyPasskeyAuthentication endpoints so that deleteVerificationValue is called with data.id instead of challengeId. As a workaround, you can patch your local installation (e.g., using yarn patch, pnpm patch, or bun patch) until a new release is available that incorporates this fix. Could you let me know if you’re seeing any other issues with your adapter, or if there’s anything else I can help clarify? Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@nilskroe commented on GitHub (Dec 17, 2025):

@better-auth-agent can you fix it and open a PR?

@nilskroe commented on GitHub (Dec 17, 2025): @better-auth-agent can you fix it and open a PR?
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 17, 2025):

Hi there! Thanks for reporting the issue with the passkey plugin. We’ve identified that the endpoints for passkey registration and authentication are indeed mistakenly using the challengeId instead of the actual document ID (data.id) when calling deleteVerificationValue. The fix will update both occurrences to use data.id, ensuring that adapters with strict ID validation (like Convex) work correctly.

Next steps:

  1. We’ll prepare a patch that updates the deletion calls in the passkey routes to pass data.id.
  2. Once validated with our tests, we’ll open a PR with these changes.
  3. We encourage you to let us know if you have any specific test scenarios or additional context that should be considered.

Does this approach work for you, or is there another aspect you'd like to discuss further? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 17, 2025): Hi there! Thanks for reporting the issue with the passkey plugin. We’ve identified that the endpoints for passkey registration and authentication are indeed mistakenly using the challengeId instead of the actual document ID (data.id) when calling deleteVerificationValue. The fix will update both occurrences to use data.id, ensuring that adapters with strict ID validation (like Convex) work correctly. Next steps: 1. We’ll prepare a patch that updates the deletion calls in the passkey routes to pass data.id. 2. Once validated with our tests, we’ll open a PR with these changes. 3. We encourage you to let us know if you have any specific test scenarios or additional context that should be considered. Does this approach work for you, or is there another aspect you'd like to discuss further? Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@GautamBytes commented on GitHub (Dec 17, 2025):

will work on it

@GautamBytes commented on GitHub (Dec 17, 2025): will work on it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2553