From df9cf53d2b42e8a1e0f2a77ee71c788a23d03656 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Thu, 25 May 2023 11:47:23 +0200 Subject: [PATCH] Use `sandbox` attibute for iframes created by Keycloak JS (#20544) --- js/libs/keycloak-js/src/keycloak.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/libs/keycloak-js/src/keycloak.js b/js/libs/keycloak-js/src/keycloak.js index 388e7541ba..2287ac3747 100755 --- a/js/libs/keycloak-js/src/keycloak.js +++ b/js/libs/keycloak-js/src/keycloak.js @@ -187,6 +187,7 @@ function Keycloak (config) { var ifrm = document.createElement("iframe"); var src = kc.createLoginUrl({prompt: 'none', redirectUri: kc.silentCheckSsoRedirectUri}); ifrm.setAttribute("src", src); + ifrm.setAttribute("sandbox", "allow-scripts allow-same-origin"); ifrm.setAttribute("title", "keycloak-silent-check-sso"); ifrm.style.display = "none"; document.body.appendChild(ifrm); @@ -1202,6 +1203,7 @@ function Keycloak (config) { var src = kc.endpoints.checkSessionIframe(); iframe.setAttribute('src', src ); + iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin'); iframe.setAttribute('title', 'keycloak-session-iframe' ); iframe.style.display = 'none'; document.body.appendChild(iframe); @@ -1274,6 +1276,7 @@ function Keycloak (config) { if (loginIframe.enable || kc.silentCheckSsoRedirectUri) { var iframe = document.createElement('iframe'); iframe.setAttribute('src', kc.endpoints.thirdPartyCookiesIframe()); + iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin'); iframe.setAttribute('title', 'keycloak-3p-check-iframe' ); iframe.style.display = 'none'; document.body.appendChild(iframe);