Skip to content

[CVE-2026-107889] Stored XSS on the login page via kcSanitize bypass #53813

Closed

Description

@abstractj

Describe the bug

A stored cross-site scripting (XSS) vulnerability exists in Keycloak's login theme rendering. A realm administrator with the manage-realm permission can store malicious HTML in realm display fields (such as displayNameHtml). This content is rendered on the pre-authentication login page and can execute arbitrary JavaScript in the browser of any user who visits that realm's login page, without requiring additional interaction beyond loading the page. The vulnerability stems from the HTML sanitization pipeline used to process admin-supplied HTML: the kcSanitize filter leaves certain numeric character references inert, but the subsequent fixURLs() post-processor restores the & encoding back to &, re-activating those references before the browser parses them. A no-click variant also affects the WebAuthn error page.

Version

26.1.3 to 26.8.0

Expected behavior

Admin-supplied HTML stored in realm display fields (such as displayNameHtml) is sanitized such that no JavaScript can execute when the login page is rendered, regardless of the encoding or formatting of the stored value. The sanitization result should be stable and consistent with what the browser ultimately interprets.

Actual behavior

Admin-supplied HTML containing a crafted JavaScript URL passes through the sanitization step (kcSanitize) and is re-activated by the fixURLs() post-processor, resulting in executable script being rendered on the login page for all users in the realm.


This issue was originally tracked in the private repository. Migrated by @abstractj.

Activity

  1. added
    area/authentication
    priority/important
    area/account/ui
    kind/cve
    on Oct 9, 2026
  2. added theissue type on Oct 9, 2026
  3. changed the title [-][CVE-2026-107889] Responsible disclosure - stored XSS on the login page via kcSanitize bypass (PoC attached)[/-] [+][CVE-2026-107889] Stored XSS on the login page via kcSanitize bypass[/+] on Oct 9, 2026
  4. self-assigned this
    on Oct 9, 2026
  5. 4 remaining items

  6. mabartos commented on Oct 14, 2026

    @mabartos
    Member

    @michalvavrik Could you please create backports for 26.6 and 26.8? Thanks!

  7. michalvavrik commented on Oct 14, 2026

    @michalvavrik
    Member

    14. @michalvavrik Could you please create backports for 26.6 and 26.8? Thanks!

    don't worry, I didn't forget, please find linked PRs and get reviews and merge; thanks for the ping

  8. added
    severity/medium
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/account/uiarea/authenticationkind/cvepriority/importantrelease/26.6.8release/26.8.2release/27.0.0severity/mediumteam/core-authnteam/core-shared

Type

Fields

No fields configured for cve.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions