[PR #8011] [MERGED] fix(social): add error handling for id token verification in Apple and Google providers #7687

Closed
opened 2026-03-13 13:45:40 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8011
Author: @Paola3stefania
Created: 2/17/2026
Status: Merged
Merged: 2/17/2026
Merged by: @Bekacru

Base: canaryHead: fix/apple-google-verify-id-token-error-handling


📝 Commits (2)

  • e6f477f try ctacth block
  • 2407427 Merge branch 'canary' into fix/apple-google-verify-id-token-error-handling

📊 Changes

2 files changed (+41 additions, -33 deletions)

View changed files

📝 packages/core/src/social-providers/apple.ts (+25 -21)
📝 packages/core/src/social-providers/google.ts (+16 -12)

📄 Description

addresses https://github.com/better-auth/better-auth/issues/7550

Summary by cubic

Add robust error handling to Apple and Google ID token verification so invalid or malformed tokens fail gracefully instead of throwing. This prevents crashes and makes social login more reliable.

  • Bug Fixes
    • Wrap decodeProtectedHeader, public key fetch, and jwtVerify in try/catch for both providers; return false on any error.
    • Enforce nonce checks; return false on mismatch. Apple keeps boolean normalization for email fields and audience fallback.

Written for commit 2407427144. Summary will update 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/8011 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 2/17/2026 **Status:** ✅ Merged **Merged:** 2/17/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/apple-google-verify-id-token-error-handling` --- ### 📝 Commits (2) - [`e6f477f`](https://github.com/better-auth/better-auth/commit/e6f477fe791b9c71553eb91cb4f02241fe8a9c97) try ctacth block - [`2407427`](https://github.com/better-auth/better-auth/commit/24074271444e6bc66b99db5dd667f609b16aeca6) Merge branch 'canary' into fix/apple-google-verify-id-token-error-handling ### 📊 Changes **2 files changed** (+41 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/social-providers/apple.ts` (+25 -21) 📝 `packages/core/src/social-providers/google.ts` (+16 -12) </details> ### 📄 Description addresses https://github.com/better-auth/better-auth/issues/7550 <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add robust error handling to Apple and Google ID token verification so invalid or malformed tokens fail gracefully instead of throwing. This prevents crashes and makes social login more reliable. - **Bug Fixes** - Wrap decodeProtectedHeader, public key fetch, and jwtVerify in try/catch for both providers; return false on any error. - Enforce nonce checks; return false on mismatch. Apple keeps boolean normalization for email fields and audience fallback. <sup>Written for commit 24074271444e6bc66b99db5dd667f609b16aeca6. Summary will update 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:45:40 -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#7687