[PR #5624] [MERGED] fix: urls without protocol shouldn't be able to satisfy a wildcard origin #6121

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5624
Author: @Bekacru
Created: 10/27/2025
Status: Merged
Merged: 10/27/2025
Merged by: @Bekacru

Base: canaryHead: fix/url


📝 Commits (2)

  • 3a7c1d3 fix: urls without protocol shouldn't be able to satisify a wildcard origin
  • 20ce6a1 update snapshot

📊 Changes

6 files changed (+44 additions, -7 deletions)

View changed files

📝 docs/content/docs/reference/options.mdx (+6 -3)
📝 packages/better-auth/src/__snapshots__/init.test.ts.snap (+1 -0)
📝 packages/better-auth/src/api/middlewares/origin-check.test.ts (+25 -0)
📝 packages/better-auth/src/api/middlewares/origin-check.ts (+10 -3)
📝 packages/better-auth/src/db/get-tables.ts (+1 -0)
📝 packages/better-auth/src/utils/url.ts (+1 -1)

📄 Description

Summary by cubic

Hardened origin validation so URLs without a protocol can’t satisfy wildcard trusted origins, preventing malicious callback URL bypasses. Updated docs and tests, plus a small safety tweak to the user table.

  • Bug Fixes
    • Reject callback URLs without protocol for wildcard trustedOrigins; getHost returns null on parse errors and origin check fails safely.
    • Added test to block “malicious.com?.example.com” when trustedOrigins includes "*.example.com".
    • Docs: removed protocol-less wildcard example and added a warning to use a protocol (e.g., https://*.example.com).
    • DB: set user.emailVerified to input: false to prevent client-provided values.

🔄 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/5624 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 10/27/2025 **Status:** ✅ Merged **Merged:** 10/27/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/url` --- ### 📝 Commits (2) - [`3a7c1d3`](https://github.com/better-auth/better-auth/commit/3a7c1d3bfd2c941b3b9e4f85379083a3bb85e338) fix: urls without protocol shouldn't be able to satisify a wildcard origin - [`20ce6a1`](https://github.com/better-auth/better-auth/commit/20ce6a1fcc0497c64abcb199ad0915a945d36982) update snapshot ### 📊 Changes **6 files changed** (+44 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/reference/options.mdx` (+6 -3) 📝 `packages/better-auth/src/__snapshots__/init.test.ts.snap` (+1 -0) 📝 `packages/better-auth/src/api/middlewares/origin-check.test.ts` (+25 -0) 📝 `packages/better-auth/src/api/middlewares/origin-check.ts` (+10 -3) 📝 `packages/better-auth/src/db/get-tables.ts` (+1 -0) 📝 `packages/better-auth/src/utils/url.ts` (+1 -1) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Hardened origin validation so URLs without a protocol can’t satisfy wildcard trusted origins, preventing malicious callback URL bypasses. Updated docs and tests, plus a small safety tweak to the user table. - **Bug Fixes** - Reject callback URLs without protocol for wildcard trustedOrigins; getHost returns null on parse errors and origin check fails safely. - Added test to block “malicious.com?.example.com” when trustedOrigins includes "*.example.com". - Docs: removed protocol-less wildcard example and added a warning to use a protocol (e.g., https://*.example.com). - DB: set user.emailVerified to input: false to prevent client-provided values. <!-- 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:48:27 -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#6121