Skip to content

Commit 245dd26

Browse files
authored
Enforce authTokenSyncURL being a path and not a url. (#8056)
1 parent e60188d commit 245dd26

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/thirty-otters-hug.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/auth': patch
3+
---
4+
5+
Fix possible XSS vulnerability through **FIREBASE_DEFAULTS** settings.

packages/auth/src/platform_browser/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ export function getAuth(app: FirebaseApp = getApp()): Auth {
8989
]
9090
});
9191

92-
const authTokenSyncUrl = getExperimentalSetting('authTokenSyncURL');
93-
if (authTokenSyncUrl) {
94-
const mintCookie = mintCookieFactory(authTokenSyncUrl);
92+
const authTokenSyncPath = getExperimentalSetting('authTokenSyncURL');
93+
// Don't allow urls (XSS possibility), only paths on the same domain
94+
// (starting with '/')
95+
if (authTokenSyncPath && authTokenSyncPath.startsWith('/')) {
96+
const mintCookie = mintCookieFactory(authTokenSyncPath);
9597
beforeAuthStateChanged(auth, mintCookie, () =>
9698
mintCookie(auth.currentUser)
9799
);

0 commit comments

Comments
 (0)