Skip to content

Commit

Permalink
Enforce authTokenSyncURL being a path and not a url. (#8056)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored Mar 6, 2024
1 parent e60188d commit 245dd26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-otters-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/auth': patch
---

Fix possible XSS vulnerability through **FIREBASE_DEFAULTS** settings.
8 changes: 5 additions & 3 deletions packages/auth/src/platform_browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand Down

0 comments on commit 245dd26

Please sign in to comment.