Kimi K3.1 Pro · Balanced

add-html-sanitizer-for-translated-message-resources-keycloak

Keycloak · Java · M · 100–299 lines · 6 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
2 of 2
Comments published
6
Comments matching a bug
2
Comments not matching
4
Cost of this PR
$1.468

Published comments (6)

mediumbugjs/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties:188

Multivalued-size error uses ICU syntax unsupported by i18next — `setUserProfileServerError` uses plain i18next, so the single-brace placeholders and `{2,choice,...}` render literally instead of formatting the error. Use `{{0}}`-style placeholders and plain plural wording here and in admin-ui's `messages_en.properties`, or configure ICU formatting at both consumers.

mediumbugthemes/src/main/resources-community/theme/base/account/messages/messages_lt.properties:101

TOTP setup instructions are Italian in the Lithuanian message resources — The `totpStep1` replacement makes Lithuanian users see Italian instructions during TOTP setup, and `login/messages/messages_lt.properties` contains the same text. Restore Lithuanian translations in both message resources.

mediumbugthemes/src/main/resources-community/theme/base/account/messages/messages_zh_CN.properties:112

totpStep1 contains Traditional Chinese in the zh_CN bundle — Replace the value with Simplified Chinese, such as `在您的手机上安装以下应用程序之一:`.

mediumsecuritymisc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:124-126

Choice replacement hides HTML from `VerifyMessageProperties` — An `onerror` payload inside `{2,choice,...}` can be reduced to `...` and never reach sanitization. Restrict `value.replaceAll` to numeric `<` operators, or sanitize each choice branch so embedded HTML is verified.

mediumsecuritymisc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:150-155

`santizeAnchors` lets unsafe anchor URLs bypass sanitization — An English `javascript:` URL can pass verification because `santizeAnchors` deletes matching anchors before `PolicyFactory.sanitize` and compares the value with itself after stripping. Validate anchors with an `a`/`href` policy and safe URL protocols instead of removing them.

mediumbugmisc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:102-111

Auto-closed HTML tags cause StringIndexOutOfBoundsException — Auto-closing `<p>` to `<p></p>` can overlap the common prefix and suffix, giving `value.substring` a begin index past its end index and throwing `StringIndexOutOfBoundsException`. Cap the suffix scan at `value.length() - start` and `sanitized.length() - start` so this input reports a validation message.

Gold bugs found (2)

mediumThe diff-trimming code computes common prefix and suffix independently, so they can overlap and substring throws StringIndexOutOfBoundsException, crashing the verifier instead of reporting the illegal HTML.
mediumThe account and admin UI bundles now use Java MessageFormat placeholders and choice syntax for error-invalid-multivalued-size, but i18next expects {{n}}, so the UI shows literal {0}/{1}/{2} and the raw choice text.

Gold bugs missed (0)

None.