From ed0ad61bc42b05d56b6dda38a3b34b6dec0256c1 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:38:25 +0530 Subject: [PATCH] Verify SSO window message origin (#2686) --- src/app/components/uia-stages/SSOStage.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/components/uia-stages/SSOStage.tsx b/src/app/components/uia-stages/SSOStage.tsx index f85bcb30..e3d6126a 100644 --- a/src/app/components/uia-stages/SSOStage.tsx +++ b/src/app/components/uia-stages/SSOStage.tsx @@ -26,7 +26,12 @@ export function SSOStage({ useEffect(() => { const handleMessage = (evt: MessageEvent) => { - if (ssoWindow && evt.data === 'authDone' && evt.source === ssoWindow) { + if ( + evt.origin === new URL(ssoRedirectURL).origin && + ssoWindow && + evt.data === 'authDone' && + evt.source === ssoWindow + ) { ssoWindow.close(); setSSOWindow(undefined); handleSubmit(); @@ -37,7 +42,7 @@ export function SSOStage({ return () => { window.removeEventListener('message', handleMessage); }; - }, [ssoWindow, handleSubmit]); + }, [ssoWindow, handleSubmit, ssoRedirectURL]); return (