Repository navigation
Prevent kcSanitize bypass that reactivates URLs with JavaScript scheme on the login page - #53886
Conversation
- closes: [CVE-2026-107889] Stored XSS on the login page via kcSanitize bypass #53813
There was a problem hiding this comment.
🔵 Needs a closer look
The parser-sensitive security fix warrants final human validation against browser URL parsing behavior.
0 open findings
What changed in this PR
Hardens login-theme HTML sanitization against numeric-character-reference URL scheme bypasses.
Changes:
- Revalidates decoded links against allowed protocols.
- Adds sanitizer regression tests for encoded JavaScript/VBScript schemes.
- Adds login-page integration coverage while preserving benign markup.
| File | Description |
|---|---|
services/src/main/java/org/keycloak/theme/KeycloakSanitizerMethod.java |
Decodes numeric entities and rejects disallowed schemes. |
services/src/test/java/org/keycloak/theme/KeycloakSanitizerTest.java |
Tests malicious and legitimate sanitizer inputs. |
tests/base/src/test/java/org/keycloak/tests/forms/LoginPageDisplayNameHtmlSanitizationTest.java |
Verifies rendered login-page sanitization. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
@michalvavrik Thanks! Agree to go with this approach, as I don't think we can find better approach to not also break the email templates and custom display names.
I've added some suggestions to improve tests and have the full coverage. Let me know WDYT.
…nk fixup closes: github.com/keycloak/issues/53813 Signed-off-by: Michal Vavřík <dev@michalvavrik.net>
c88e89c to
1c5e0d3
Compare
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.cluster.ComponentInvalidationClusterTest#crudWithFailover |
There was a problem hiding this comment.
Thanks @michalvavrik, @mabartos and @vaceksimon! LGTM! I have been doing some tests and I think I cannot trick the html display now. I don't like the idea that sometimes we create link with empty href and sometimes no link at all, but we cannot go into owasp sanitizer to change it.