From 39d1fa2825c6d7b1e759968babe7713b21045c07 Mon Sep 17 00:00:00 2001 From: Alexander Schwartz Date: Thu, 27 Nov 2025 11:16:21 +0100 Subject: [PATCH] Escape passkeys descriptions and labels depending on the context Closes #44387 Signed-off-by: Alexander Schwartz --- .../registration/PolicyJsInjectionTest.java | 2 +- ...ogin-passkeys-conditional-authenticate.ftl | 32 ++++++++++--------- .../resources/theme/base/login/passkeys.ftl | 14 ++++---- .../base/login/webauthn-authenticate.ftl | 24 +++++++------- .../theme/base/login/webauthn-register.ftl | 30 +++++++++-------- .../login/webauthn-authenticate.ftl | 23 +++++++------ .../keycloak.v2/login/webauthn-register.ftl | 30 +++++++++-------- 7 files changed, 84 insertions(+), 71 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/webauthn/registration/PolicyJsInjectionTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/webauthn/registration/PolicyJsInjectionTest.java index d4d78ee2bcd..fd0bf4c9f25 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/webauthn/registration/PolicyJsInjectionTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/webauthn/registration/PolicyJsInjectionTest.java @@ -160,7 +160,7 @@ public class PolicyJsInjectionTest extends AbstractWebAuthnVirtualTest { assertThat(authenticators, notNullValue()); assertThat(authenticators.getItems(), not(Matchers.empty())); - assertThat(authenticators.getLabels().get(0), is("label`;window.prompt(\"another\");")); + assertThat(authenticators.getLabels().get(0), is(originalLabel)); } } diff --git a/themes/src/main/resources/theme/base/login/login-passkeys-conditional-authenticate.ftl b/themes/src/main/resources/theme/base/login/login-passkeys-conditional-authenticate.ftl index 05b9da7f9fa..f37a787dcc1 100644 --- a/themes/src/main/resources/theme/base/login/login-passkeys-conditional-authenticate.ftl +++ b/themes/src/main/resources/theme/base/login/login-passkeys-conditional-authenticate.ftl @@ -3,7 +3,7 @@ <#if section = "title"> title <#elseif section = "header"> - ${kcSanitize(msg("passkey-login-title"))?no_esc} + ${msg("passkey-login-title")} <#elseif section = "form">
@@ -24,7 +24,7 @@ <#if shouldDisplayAuthenticators?? && shouldDisplayAuthenticators> <#if authenticators.authenticators?size gt 1> -

${kcSanitize(msg("passkey-available-authenticators"))?no_esc}

+

${msg("passkey-available-authenticators")}

@@ -36,14 +36,14 @@
- ${kcSanitize(msg('${authenticator.label}'))?no_esc} + ${authenticator.label}
<#if authenticator.transports?? && authenticator.transports.displayNameProperties?has_content>
<#list authenticator.transports.displayNameProperties as nameProperty> - ${kcSanitize(msg('${nameProperty!}'))?no_esc} + ${msg(nameProperty)} <#if nameProperty?has_next> , @@ -53,10 +53,10 @@
- ${kcSanitize(msg('passkey-createdAt-label'))?no_esc} + ${msg('passkey-createdAt-label')} - ${kcSanitize(authenticator.createdAt)?no_esc} + ${authenticator.createdAt}
@@ -92,7 +92,7 @@
@@ -100,17 +100,18 @@
<#elseif section = "info"> diff --git a/themes/src/main/resources/theme/base/login/passkeys.ftl b/themes/src/main/resources/theme/base/login/passkeys.ftl index 6e3328fa37b..24db6a1cef1 100644 --- a/themes/src/main/resources/theme/base/login/passkeys.ftl +++ b/themes/src/main/resources/theme/base/login/passkeys.ftl @@ -16,28 +16,30 @@
- ${kcSanitize(msg("webauthn-doAuthenticate"))?no_esc} + ${msg("webauthn-doAuthenticate")} diff --git a/themes/src/main/resources/theme/base/login/webauthn-authenticate.ftl b/themes/src/main/resources/theme/base/login/webauthn-authenticate.ftl index ad767cfb300..748be5420b8 100644 --- a/themes/src/main/resources/theme/base/login/webauthn-authenticate.ftl +++ b/themes/src/main/resources/theme/base/login/webauthn-authenticate.ftl @@ -3,7 +3,7 @@ <#if section = "title"> title <#elseif section = "header"> - ${kcSanitize(msg("webauthn-login-title"))?no_esc} + ${msg("webauthn-login-title")} <#elseif section = "form">
@@ -25,7 +25,7 @@ <#if shouldDisplayAuthenticators?? && shouldDisplayAuthenticators> <#if authenticators.authenticators?size gt 1> -

${kcSanitize(msg("webauthn-available-authenticators"))?no_esc}

+

${msg("webauthn-available-authenticators")}

@@ -37,14 +37,14 @@
- ${kcSanitize(msg('${authenticator.label}'))?no_esc} + ${authenticator.label}
<#if authenticator.transports?? && authenticator.transports.displayNameProperties?has_content>
<#list authenticator.transports.displayNameProperties as nameProperty> - ${kcSanitize(msg('${nameProperty!}'))?no_esc} + ${msg(nameProperty)} <#if nameProperty?has_next> , @@ -54,10 +54,10 @@
- ${kcSanitize(msg('webauthn-createdAt-label'))?no_esc} + ${msg('webauthn-createdAt-label')} - ${kcSanitize(authenticator.createdAt)?no_esc} + ${authenticator.createdAt}
@@ -70,26 +70,28 @@
<#elseif section = "info"> diff --git a/themes/src/main/resources/theme/base/login/webauthn-register.ftl b/themes/src/main/resources/theme/base/login/webauthn-register.ftl index 7fa4a91316a..f9a61477d31 100644 --- a/themes/src/main/resources/theme/base/login/webauthn-register.ftl +++ b/themes/src/main/resources/theme/base/login/webauthn-register.ftl @@ -6,7 +6,7 @@ title <#elseif section = "header"> - ${kcSanitize(msg("webauthn-registration-title"))?no_esc} + ${msg("webauthn-registration-title")} <#elseif section = "form"> @@ -22,28 +22,30 @@
title <#elseif section = "header"> - ${kcSanitize(msg("webauthn-login-title"))?no_esc} + ${msg("webauthn-login-title")} <#elseif section = "form">
@@ -104,19 +105,21 @@
<#elseif section = "info"> diff --git a/themes/src/main/resources/theme/keycloak.v2/login/webauthn-register.ftl b/themes/src/main/resources/theme/keycloak.v2/login/webauthn-register.ftl index 2f5c8061d19..105b6240b5a 100644 --- a/themes/src/main/resources/theme/keycloak.v2/login/webauthn-register.ftl +++ b/themes/src/main/resources/theme/keycloak.v2/login/webauthn-register.ftl @@ -7,7 +7,7 @@ title <#elseif section = "header"> - ${kcSanitize(msg("webauthn-registration-title"))?no_esc} + ${msg("webauthn-registration-title")} <#elseif section = "form">
@@ -23,28 +23,30 @@ <@buttons.actionGroup horizontal=true>