From 123f30eb6bbd74e129abbcac329a2667a2d1a7ac Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Mon, 13 Sep 2021 08:13:55 +0200 Subject: [PATCH] Fixed: Found a new XXE (XML External Entity Injection) vulnerability in EntityImport (OFBIZ-12304) The XXE vulnerability can read arbitrary files on the server. Thanks: thiscodecc for reporting this security issue (post-auth) --- .../org/apache/ofbiz/base/util/UtilValidate.java | 12 ++++++++++++ .../org/apache/ofbiz/webtools/WebToolsServices.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java index d2d44fb544..07b47df085 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java @@ -833,6 +833,18 @@ public final class UtilValidate { return s.indexOf("://") != -1; } + /** + * urlInString returns true if the string contains :// and not "component://" + * @param s String to validate + * @return true if s contains :// and not "component://" + */ + public static boolean urlInString(String s) { + if (isEmpty(s) || s.contains("component://")) { + return false; + } + return s.indexOf("://") != -1; + } + /** * isValidUrl returns true if the string is a valid URL (using Commons UrlValidator) * @param s String to validate diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java index be32378272..206aae93ec 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java @@ -143,7 +143,7 @@ public class WebToolsServices { // ############################# // FM Template // ############################# - if (UtilValidate.URLInString(fulltext)) { + if (UtilValidate.urlInString(fulltext)) { Debug.logError("For security reason HTTP URLs are not accepted, see OFBIZ-12304", MODULE); Debug.logInfo("Rather load your data from a file", MODULE); return null;