-
Notifications
You must be signed in to change notification settings - Fork 0
Add HTML sanitizer for translated message resources #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-html-sanitizer-baseline
Are you sure you want to change the base?
Add HTML sanitizer for translated message resources #68
Conversation
Closes #37428 Signed-off-by: Alexander Schwartz <[email protected]>
|
@claude review this PR |
1 similar comment
|
@claude review this PR |
|
Claude finished @akshayutture-augment's task —— View job PR Review Complete ✓I've reviewed this HTML sanitizer implementation for translated message resources. This is a security-focused feature to prevent XSS vulnerabilities in internationalized content. Here's my analysis: 🔒 Security ImplementationOverall Approach: The implementation uses OWASP Java HTML Sanitizer to validate translated message properties against their English source, which is a solid defensive strategy. Strengths:
🐛 Critical Issues1. Typo in Method Name (misc/theme-verifier/src/main/java/org/keycloak/themeverifier/VerifyMessageProperties.java:150)private String santizeAnchors(String key, String value, String englishValue) {Should be 2. Logic Error in Anchor Validation (VerifyMessageProperties.java:150-162)The anchor sanitization logic has a fundamental flaw: private String santizeAnchors(String key, String value, String englishValue) {
Matcher matcher = ANCHOR_PATTERN.matcher(value);
Matcher englishMatcher = ANCHOR_PATTERN.matcher(englishValue);
while (matcher.find()) {
if (englishMatcher.find() && Objects.equals(matcher.group(), englishMatcher.group())) {
value = value.replaceFirst(Pattern.quote(englishMatcher.group()), "");
} else {
messages.add("Didn't find anchor tag " + matcher.group() + " in original string");
break;
}
}
return value;
}Problems:
Expected behavior: Should either:
3. Incomplete HTML Tag Pattern (VerifyMessageProperties.java:139)Pattern HTML_TAGS = Pattern.compile("<[a-z]+[^>]*>");This pattern only matches lowercase HTML tags, but HTML is case-insensitive. While most/all message files likely use lowercase, this could miss uppercase or mixed-case tags like Recommendation: Use case-insensitive pattern:
|
Test 7
Replicated from ai-code-review-evaluation/keycloak-greptile#7