CVE-2020-28337 (published 2021-02-15T20:15Z)

A directory traversal issue in the Utils/Unzip module in Microweber through 1.1.20 allows an authenticated attacker to gain remote code execution via the backup restore feature. To exploit the vulnerability, an attacker must have the credentials of an administrative user, upload a maliciously constructed ZIP file with file paths including relative paths (i.e., ../../), move this file into the backup directory, and execute a restore on this file.

Severity: MEDIUM
CVSS v2 base score: 6.5 (AV:N/AC:L/Au:S/C:P/I:P/A:P)
CVSS v3 base score: 7.2, HIGH (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/microweber/microweber
commit_details: repo_url: https://github.com/microweber/microweber
author: bobimicroweber
author_date: 2020-11-04 11:43:08+02:00
msg: update
repository: repo_url: https://github.com/microweber/microweber
repo_name: microweber/microweber
description: Drag and Drop Website Builder and CMS with E-commerce
repo_language: HTML
owner: microweber
file_changes: filename: Unzip.php
change_type: ModificationType.MODIFY
diff: @@ -82,14 +82,19 @@ class Unzip
             }
 
         } else if (function_exists('gzinflate')) {
+
             if (!$files = $this->_list_files()) {
                 $this->set_error('ZIP folder was empty.');
-
                 return false;
             }
 
             $file_locations = array();
             foreach ($files as $file => $trash) {
+
+                if (strpos($file,'..') !== false) {
+                    continue;
+                }
+
                 $dirname = pathinfo($file, PATHINFO_DIRNAME);
                 $extension = (pathinfo($file, PATHINFO_EXTENSION));
 
@@ -205,12 +210,17 @@ class Unzip
                 $name = dirname($name);
                 $is_dir_there = $target_dir . $name;
 
+                if (strpos($is_dir_there,'..') !== false) {
+                   continue;
+                }
+
                 if ($name != '.') {
                     $dirs_tree[] = $is_dir_there;
 
                 }
 
             }
+
             $dirs_tree = array_unique($dirs_tree);
 
             foreach ($dirs_tree as $item) {
@@ -238,6 +248,11 @@ class Unzip
                     $size = zip_entry_filesize($entry);
                     $name = zip_entry_name($entry);
                     $target_file_to_save = normalize_path($target_dir . $name, false);
+
+                    if (strpos($target_file_to_save,'..') !== false) {
+                        continue;
+                    }
+
                     $target_file_to_save_dir = dirname($target_file_to_save);
                     if(!is_dir($target_file_to_save_dir)){
                         mkdir_recursive($target_file_to_save_dir);
@@ -263,8 +278,9 @@ class Unzip
                 }
                 zip_close($archive);
             }
-
-            return $file_locations;
+            if (!empty($file_locations)) {
+                $file_locations = array_unique($file_locations);
+            }
         }
 
         return $file_locations;
@@ -569,6 +585,14 @@ class Unzip
      */
     private function _extract_file($compressed_file_name, $target_file_name = false, $underscore_case = false)
     {
+        if (strpos($target_file_name,'..') !== false) {
+            return false;
+        }
+
+        if (strpos($compressed_file_name,'..') !== false) {
+            return false;
+        }
+
         if (!sizeof($this->compressed_list)) {
             $this->set_debug('Trying to unzip before loading file list... Loading it!');
             $this->_list_files(false, $compressed_file_name);

programming_language: PHP
filename: style.css
change_type: ModificationType.MODIFY
diff: @@ -140,6 +140,7 @@
     border-radius: 4px;
     margin-top: 15px;
     margin-bottom: 15px;
+    overflow-y: scroll;
 }
 
 .js-export-log:empty {

programming_language: CSS