ISSUE DESCRIPTION: *[MAJOR]* _functional_ @SsoReauth@.@handleSsoReauth@: postMessage contract has no nonce or session identifier — any frame on @serverOrigin@ (e.g. compromised iframe, XSS) can fake @{type:'sso-reauth-success'}@ and dismiss the overlay without an actual re-auth. Include a server-issued state/nonce that ties the message to the in-progress reauth. PROPOSED FIX: Have the server generate a cryptographic nonce when issuing @MSG_SSO_REAUTH@, embed it as the OIDC @state@ on the @reauthUrl@ and validate it in @handleReauthCallback@; emit the same nonce back to the opener inside the postMessage payload (and never use @'*'@ as targetOrigin). On the client, capture the nonce from @MSG_SSO_REAUTH@, validate @event.data.nonce === expectedNonce@ before treating any message as authoritative, and reject mismatches. CHANGES: Before (lines 320-336, inside handleReauthCallback): boolean success = false; SsoAuthenticator ssoAuth = SecurityManager.getInstance().ssoSm.getSsoAuthenticator(); if (code != null && !code.isEmpty() && ssoAuth instanceof OidcSsoAuthenticator) { OidcSsoAuthenticator oidc = (OidcSsoAuthenticator) ssoAuth; SsoAuthenticator.Result result = oidc.processReauthCallback(code, state); success = (result != null && result.isSuccess()); } String msgType = success ? "sso-reauth-success" : "sso-reauth-failed"; String html = ""; After: boolean success = false; String nonce = null; SsoAuthenticator ssoAuth = SecurityManager.getInstance().ssoSm.getSsoAuthenticator(); if (code != null && !code.isEmpty() && ssoAuth instanceof OidcSsoAuthenticator) { OidcSsoAuthenticator oidc = (OidcSsoAuthenticator) ssoAuth; // processReauthCallback already validates the OIDC state -- the // nonce we round-trip below is the same value, also issued by the // server when MSG_SSO_REAUTH was pushed to the client. SsoAuthenticator.Result result = oidc.processReauthCallback(code, state); success = (result != null && result.isSuccess()); if (success) { nonce = state; // safe: validated server-side } } String msgType = success ? "sso-reauth-success" : "sso-reauth-failed"; // Restrict targetOrigin to the server's own origin (never '*') and // include the nonce so the opener can bind this message to the in-flight // reauth and reject forged messages from same-origin iframes / XSS. String origin = request.getHttpURI().getScheme() + "://" + request.getHttpURI().getHost() + (request.getHttpURI().getPort() > 0 ? ":" + request.getHttpURI().getPort() : ""); String nonceJs = (nonce == null) ? "null" : "'" + nonce.replace("\\", "\\\\").replace("'", "\\'") + "'"; String html = ""; Before (around lines 134-148 and 268-300): function handleSsoReauth(reauthUrl, reauthTimeoutSec) { ... let serverOrigin = window.location.origin; try { serverOrigin = new URL(p2j.socket.getLogoutPage()).origin; } catch(e) {} cleanupReauthUi(false); ... reauthMessageListener = function(event) { if (event.origin !== serverOrigin) { return; } if (!event.data || typeof event.data.type !== 'string') { return; } if (event.data.type === 'sso-reauth-success') { After: function handleSsoReauth(reauthUrl, reauthTimeoutSec, reauthNonce) { ... let serverOrigin = window.location.origin; try { serverOrigin = new URL(p2j.socket.getLogoutPage()).origin; } catch(e) {} // Nonce binds postMessage events to this specific reauth attempt. var expectedNonce = (typeof reauthNonce === 'string' && reauthNonce.length > 0) ? reauthNonce : null; cleanupReauthUi(false); ... reauthMessageListener = function(event) { if (event.origin !== serverOrigin) { return; } if (!event.data || typeof event.data.type !== 'string') { return; } // Require nonce match; reject any same-origin spoofs (iframes/XSS). if (expectedNonce && event.data.nonce !== expectedNonce) { console.warn('SSO re-auth: ignoring message with mismatched nonce'); return; } if (event.data.type === 'sso-reauth-success') { Caller (p2j.socket.js, where MSG_SSO_REAUTH dispatches to ssoReauth.handleReauth) must pass the nonce delivered with the message; the server must include @nonce@ in the @MSG_SSO_REAUTH@ payload (same value also used as the OIDC @state@ on @reauthUrl@).