diff --git a/.changeset/bright-avocados-attack.md b/.changeset/bright-avocados-attack.md new file mode 100644 index 00000000000..b5292466b52 --- /dev/null +++ b/.changeset/bright-avocados-attack.md @@ -0,0 +1,5 @@ +--- +'@firebase/auth': patch +--- + +Do not allow double slash at beginning of authTokenSyncURL. (follow-up fix to https://github.com/firebase/firebase-js-sdk/pull/8056) diff --git a/packages/auth/src/platform_browser/index.ts b/packages/auth/src/platform_browser/index.ts index 2d21c768454..ea14f3d7aba 100644 --- a/packages/auth/src/platform_browser/index.ts +++ b/packages/auth/src/platform_browser/index.ts @@ -91,8 +91,8 @@ export function getAuth(app: FirebaseApp = getApp()): Auth { const authTokenSyncPath = getExperimentalSetting('authTokenSyncURL'); // Don't allow urls (XSS possibility), only paths on the same domain - // (starting with '/') - if (authTokenSyncPath && authTokenSyncPath.startsWith('/')) { + // (starting with a single '/') + if (authTokenSyncPath && authTokenSyncPath.match(/^\/[^\/].*/)) { const mintCookie = mintCookieFactory(authTokenSyncPath); beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser)