Skip to content

Commit

Permalink
backported commit #23656ae Use Locale.ROOT consistently for toLower/t…
Browse files Browse the repository at this point in the history
…oUpperCase to mitigate CVE-2024-38820
  • Loading branch information
cesarhernandezgt committed Nov 4, 2024
1 parent f6a6e21 commit 63c5957
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -482,7 +483,8 @@ public void setDisallowedFields(@Nullable String... disallowedFields) {
else {
String[] fieldPatterns = new String[disallowedFields.length];
for (int i = 0; i < fieldPatterns.length; i++) {
fieldPatterns[i] = PropertyAccessorUtils.canonicalPropertyName(disallowedFields[i]).toLowerCase();
String field = PropertyAccessorUtils.canonicalPropertyName(disallowedFields[i]);
fieldPatterns[i] = field.toLowerCase(Locale.ROOT);
}
this.disallowedFields = fieldPatterns;
}
Expand Down Expand Up @@ -825,7 +827,7 @@ protected boolean isAllowed(String field) {
String[] allowed = getAllowedFields();
String[] disallowed = getDisallowedFields();
return ((ObjectUtils.isEmpty(allowed) || PatternMatchUtils.simpleMatch(allowed, field)) &&
(ObjectUtils.isEmpty(disallowed) || !PatternMatchUtils.simpleMatch(disallowed, field.toLowerCase())));
(ObjectUtils.isEmpty(disallowed) || !PatternMatchUtils.simpleMatch(disallowed, field.toLowerCase(Locale.ROOT))));
}

/**
Expand Down

0 comments on commit 63c5957

Please sign in to comment.