Skip to content

sandbox="allow-scripts allow-same-origin" on the silent check-sso iframe triggers a browser warning and adds no isolation #353

Open

Description

@LasseMunk

Describe the bug

All three hidden iframes keycloak-js creates carry the same attribute:

iframe.setAttribute('sandbox', 'allow-storage-access-by-user-activation allow-scripts allow-same-origin')

(lib/keycloak.js: the third-party cookie check, the login-status iframe, and #checkSsoSilently; 26.2.4 lines 757, 894 and 978.)

Firefox logs on every page load:

An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can remove its sandboxing.

and Chromium logs the equivalent "can escape its sandboxing". The HTML standard warns against this token pair because a same-origin framed page with scripts can reach window.parent and delete the sandbox attribute from its own frame element, so the sandbox is not a boundary against that page.

For the silent check-sso frame the warning is accurate: silentCheckSsoRedirectUri is by definition a page on the application's own origin, so the sandbox restricts nothing that page could not undo. For the two IdP-hosted frames (3p-cookies/step1.html and login-status-iframe.html) the pair is harmless in practice, since a cross-origin page cannot touch the parent DOM, but the browser warns on the attribute alone.

Both tokens are needed for the mechanism as it stands: the framed pages are pure script, and silent-check-sso reads location.href and posts to parent with location.origin as the target origin, which is "null" under a unique origin; the cookie-check pages exist to set and read cookies. So an application cannot fix this from outside, and the warning lands in every integrator's console, where it reads like something they did wrong.

Version

keycloak-js 26.2.4, Keycloak server 26.5. Reproduced in Firefox 140 and Chromium (Playwright 1.62) with:

keycloak.init({
  onLoad: "check-sso",
  checkLoginIframe: false,
  silentCheckSsoRedirectUri: window.location.origin + "/silent-check-sso.html",
});

Version

keycloak-js 26.2.4, Keycloak server 26.5

Expected behavior

No sandbox warning from frames the adapter creates. Either:

  1. Drop sandbox on the silent check-sso frame, where it provides no isolation (same origin, scripts required), keeping allow-storage-access-by-user-activation only if it is actually needed there; or
  2. Keep it and document in the README, next to silentCheckSsoRedirectUri, that the warning is expected and why, so integrators stop chasing it.

Actual behavior

An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can remove its sandboxing.

How to Reproduce?

  1. Initialise as above on any page, signed out.
  2. Open the console: the warning is logged once for the silent check-sso frame (and once more for the cookie-check frame when it runs).

Anything else?

The warning is informational and nothing breaks; this is about the console noise every integrator sees and cannot act on, and about a sandbox attribute that, on the same-origin frame, promises isolation it does not provide.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions