You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2023/04/08 09:35:37 UTC

[ofbiz-framework] branch release22.01 updated (58ec8cd302 -> f65b24aed0)

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a change to branch release22.01
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


    from 58ec8cd302 Fixed: [SECURITY] CVE-2023-28708 Apache Tomcat - Information Disclosure (OFBIZ-12782)
     new 6477a8929e Fixed: Disallow string concatenation in uploaded files (OFBIZ-12794)
     new f65b24aed0 Fixed: Disallow string concatenation in uploaded files (OFBIZ-12794)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 framework/security/config/security.properties                     | 2 ++
 .../src/main/java/org/apache/ofbiz/security/SecuredUpload.java    | 8 ++++++++
 2 files changed, 10 insertions(+)


[ofbiz-framework] 01/02: Fixed: Disallow string concatenation in uploaded files (OFBIZ-12794)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release22.01
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 6477a8929e1a7f535818d277c082024c4f2e6575
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Sat Apr 8 11:06:02 2023 +0200

    Fixed: Disallow string concatenation in uploaded files (OFBIZ-12794)
    
    An external security reporter brought to our attention that a signed up user
    could upload a webshell using string concatenation. Of course there is no reason
    for a signed up user to upload a webshell. And anyway we don't create CVEs for
    signed up users trying our security.
    
    Nevertheless we have decided to fix this possibility while allowing to bypass it
    using a new security property. The later can be useful when a file must contain
    a string concatenation, images files, seen as encoded texts, come to mind.
    
    Thanks: so far unknown security reporter
---
 framework/security/config/security.properties                      | 2 ++
 .../src/main/java/org/apache/ofbiz/security/SecuredUpload.java     | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/framework/security/config/security.properties b/framework/security/config/security.properties
index 1e79caa265..44119dc361 100644
--- a/framework/security/config/security.properties
+++ b/framework/security/config/security.properties
@@ -270,6 +270,8 @@ deniedWebShellTokens=java.,beans,freemarker,<script,javascript,<body,body ,<form
                      python,perl ,/perl,ruby ,/ruby,process,function,class,InputStream,to_server,wget ,static,assign,webappPath,\
                      ifconfig,route,crontab,netstat,uname ,hostname,iptables,whoami,"cmd",*cmd|,+cmd|,=cmd|,localhost,thread,require,gzdeflate
 
+allowStringConcatenationInUploadedFiles=false
+
 #-- Max line length for uploaded files, by default 10000
 maxLineLength=
 
diff --git a/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java b/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
index fb9fd68ed3..1b0a851761 100644
--- a/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
+++ b/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
@@ -105,8 +105,15 @@ public class SecuredUpload {
     private static final List<String> DENIEDFILEEXTENSIONS = getDeniedFileExtensions();
     private static final List<String> DENIEDWEBSHELLTOKENS = getDeniedWebShellTokens();
     private static final Integer MAXLINELENGTH = UtilProperties.getPropertyAsInteger("security", "maxLineLength", 10000);
+    private static final Boolean allowStringConcatenationInUploadedFiles = UtilProperties.getPropertyAsBoolean("security", "allowStringConcatenationInUploadedFiles", false);
 
     public static boolean isValidText(String content, List<String> allowed) throws IOException {
+        String contentWithoutSpaces = content.replace(" ", "");
+        if ((contentWithoutSpaces.contains("\"+\"") || contentWithoutSpaces.contains("'+'"))
+                && !allowStringConcatenationInUploadedFiles) {
+            Debug.logInfo("The uploaded file contains a string concatenation. It can't be uploaded for security reason", MODULE);
+            return false;
+        }
         return content != null ? DENIEDWEBSHELLTOKENS.stream().allMatch(token -> isValid(content, token.toLowerCase(), allowed)) : false;
     }
 


[ofbiz-framework] 02/02: Fixed: Disallow string concatenation in uploaded files (OFBIZ-12794)

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release22.01
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit f65b24aed02738273a2ee243ccfad5a5469f4e58
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Sat Apr 8 11:06:02 2023 +0200

    Fixed: Disallow string concatenation in uploaded files (OFBIZ-12794)
    
    An external security reporter brought to our attention that a signed up user
    could upload a webshell using string concatenation. Of course there is no reason
    for a signed up user to upload a webshell. And anyway we don't create CVEs for
    signed up users trying our security.
    
    Nevertheless we have decided to fix this possibility while allowing to bypass it
    using a new security property. The later can be useful when a file must contain
    a string concatenation, images files, seen as encoded texts, come to mind.
    
    Thanks: so far unknown security reporter
---
 .../src/main/java/org/apache/ofbiz/security/SecuredUpload.java       | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java b/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
index 1b0a851761..c9c52f7051 100644
--- a/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
+++ b/framework/security/src/main/java/org/apache/ofbiz/security/SecuredUpload.java
@@ -105,12 +105,13 @@ public class SecuredUpload {
     private static final List<String> DENIEDFILEEXTENSIONS = getDeniedFileExtensions();
     private static final List<String> DENIEDWEBSHELLTOKENS = getDeniedWebShellTokens();
     private static final Integer MAXLINELENGTH = UtilProperties.getPropertyAsInteger("security", "maxLineLength", 10000);
-    private static final Boolean allowStringConcatenationInUploadedFiles = UtilProperties.getPropertyAsBoolean("security", "allowStringConcatenationInUploadedFiles", false);
+    private static final Boolean ALLOWSTRINGCONCATENATIONINUPLOADEDFILES =
+            UtilProperties.getPropertyAsBoolean("security", "allowStringConcatenationInUploadedFiles", false);
 
     public static boolean isValidText(String content, List<String> allowed) throws IOException {
         String contentWithoutSpaces = content.replace(" ", "");
         if ((contentWithoutSpaces.contains("\"+\"") || contentWithoutSpaces.contains("'+'"))
-                && !allowStringConcatenationInUploadedFiles) {
+                && !ALLOWSTRINGCONCATENATIONINUPLOADEDFILES) {
             Debug.logInfo("The uploaded file contains a string concatenation. It can't be uploaded for security reason", MODULE);
             return false;
         }