Amazon Ergo 1.0 · Heavy

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

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.

Gold bugs found
3 of 7
Comments published
4
Comments matching a bug
3
Comments not matching
1
Cost of this PR
$6.482

Published comments (4)

mediumbugmisc/theme-verifier/src/test/java/org/keycloak/themeverifier/VerifyMessagePropertiesTest.java:36-52

Missing positive test for allowed HTML in translations — A regression that rejects all HTML in translations would leave this suite green while breaking CI for legitimate translations. Add a test and fixture with allowed HTML such as `<b>bold</b>` mirroring the English source, and assert that `verify()` returns an empty list.

mediumbugthemes/src/main/resources-community/theme/base/login/messages/messages_lt.properties:71

loginTotpStep1 is Italian instead of Lithuanian — Users of the `lt` locale will see Italian on the OTP setup page. Replace `loginTotpStep1` with a Lithuanian translation, such as `Įdiekite vieną iš šių programėlių į savo mobilųjį telefoną:`. **Also found in:** - `themes/src/main/resources-community/theme/base/account/messages/messages_lt.properties:101-101`

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

Java MessageFormat placeholders break i18next interpolation — The account UI will show the raw pattern instead of the attribute name and min/max values because i18next does not interpolate `{0}` or `{2,choice,...}` by default. Keep `{{0}}`, `{{1}}`, and `{{2}}` in this bundle, or configure a separate interpolation/formatting path; check `t(unWrap(e.errorMessage), params)` in `js/libs/ui-shared/src/user-profile/utils.ts`. **Also found in:** - `js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties:3138-3138`

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

Illegal HTML diagnostic can throw StringIndexOutOfBoundsException — A translation ending in an unclosed `<b>`, `<p>`, or `<strong>` can crash the verifier instead of reporting illegal HTML. Clamp `end` to the smaller of `value.length() - start` and `sanitized.length() - start` before either `substring` call. **Also found in:** - `misc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:119-128`

Gold bugs found (3)

mediumThe Lithuanian TOTP setup step was replaced with Italian text in both the account and login bundles.
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 (4)

highnormalizeValue blanks the entire choice expression for some keys before HTML validation, so markup placed inside a choice branch of those keys bypasses the new verifier.
mediumThe anchor regex </?a[^>]*> in the theme verifier treats any tag starting with 'a' (<abbr>, <area>, ...) as an anchor tag, which can produce misleading anchor errors or strip such tags before HTML sanitizing.
mediumThe illegalHtmlTag fixture uses a malformed '</div' closing tag, so the sanitizer flags it for malformation and verifyIllegalHtmlTagDetected would still pass if <div> were permitted by POLICY_SOME_HTML; the test does not isolate the forbidden-tag check.
mediumsantizeAnchors removes matching opening anchor tags without checking that the translation keeps the matching closing </a> (or the same number of anchors), so a translation with an unclosed <a ...> passes verification and renders a link that swallows the following content.