From a0d9fba0d9b0d6520f57b3b193e1ce8319a77455 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Fri, 24 May 2019 13:24:31 +0000 Subject: [PATCH] Fixed: OWASP sanitizer breaks proper rendering of HTML code (OFBIZ-10187) After a discussion with Dennis, I checked and the pattern ONSITE_URL would be useless without .allowAttributes("background").matching(ONSITE_URL) .onElements("table") .allowAttributes("background").matching(ONSITE_URL) .onElements("td", "th", "tr") So here they are Thanks: Dennis Balkir for discussion git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1859871 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/ofbiz/base/html/CustomPermissivePolicy.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java b/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java index 8501eeba01..a88c9fc034 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/html/CustomPermissivePolicy.java @@ -17,7 +17,7 @@ import com.google.common.base.Predicate; * has been subject to a few complex XSS attacks. Listings are allowed to * contain much more rich content than, say, Slashdot- so it's attack surface is * considerably larger. The following tags appear to be accepted by eBay (they - * don't publish rules): {@code },... + * don't publish rules): {@code },... */ public class CustomPermissivePolicy implements SanitizerCustomPolicy { @@ -111,11 +111,15 @@ public class CustomPermissivePolicy implements SanitizerCustomPolicy { .matching(NUMBER).onElements("table") .allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE) .onElements("table") + .allowAttributes("background").matching(ONSITE_URL) + .onElements("table") + .allowAttributes("background").matching(ONSITE_URL) + .onElements("td", "th", "tr") .allowAttributes("align").matching(ALIGN) .onElements("table") .allowAttributes("noresize").matching(Pattern.compile("(?i)noresize")) .onElements("table") - .allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE) + .allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE) .onElements("td", "th") .allowAttributes("abbr").matching(PARAGRAPH) .onElements("td", "th")