diff --git a/.changeset/thirty-otters-hug.md b/.changeset/thirty-otters-hug.md new file mode 100644 index 00000000000..6dd0c7e0059 --- /dev/null +++ b/.changeset/thirty-otters-hug.md @@ -0,0 +1,5 @@ +--- +'@firebase/auth': patch +--- + +Fix possible XSS vulnerability through **FIREBASE_DEFAULTS** settings. diff --git a/packages/auth/src/platform_browser/index.ts b/packages/auth/src/platform_browser/index.ts index 6399072d713..2d21c768454 100644 --- a/packages/auth/src/platform_browser/index.ts +++ b/packages/auth/src/platform_browser/index.ts @@ -89,9 +89,11 @@ export function getAuth(app: FirebaseApp = getApp()): Auth { ] }); - const authTokenSyncUrl = getExperimentalSetting('authTokenSyncURL'); - if (authTokenSyncUrl) { - const mintCookie = mintCookieFactory(authTokenSyncUrl); + const authTokenSyncPath = getExperimentalSetting('authTokenSyncURL'); + // Don't allow urls (XSS possibility), only paths on the same domain + // (starting with '/') + if (authTokenSyncPath && authTokenSyncPath.startsWith('/')) { + const mintCookie = mintCookieFactory(authTokenSyncPath); beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser) );