CVE-2018-20332 (published 2018-12-21T09:29Z)

An issue has been discovered in the OpenWebif plugin through 1.2.4 for Enigma2 based devices. Reading of arbitrary files is possible with /file?action=download&file= followed by a full pathname, and listing of arbitrary directories is possible with /file?action=download&dir= followed by a full pathname. This is related to plugin/controllers/file.py in the e2openplugin-OpenWebif project.

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

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/E2OpenPlugins/e2openplugin-OpenWebif
commit_details: repo_url: https://github.com/E2OpenPlugins/e2openplugin-OpenWebif
author: doubleO8
author_date: 2017-09-09 11:35:27+02:00
msg: move utilities library and actually use it
repository: repo_url: https://github.com/E2OpenPlugins/e2openplugin-OpenWebif
repo_name: E2OpenPlugins/e2openplugin-OpenWebif
description: GPL Web Interface for e2stabs
repo_language: JavaScript
owner: E2OpenPlugins
file_changes: filename: file.py
change_type: ModificationType.MODIFY
diff: @@ -19,6 +19,8 @@ from twisted.web import static, resource, http
 
 from Components.config import config
 from Tools.Directories import fileExists
+from utilities import lenient_force_utf_8, sanitise_filename_slashes
+
 
 def new_getRequestHostname(self):
 	host = self.getHeader(b'host')
@@ -38,8 +40,8 @@ class FileController(resource.Resource):
 			action = request.args["action"][0]
 
 		if "file" in request.args:
-			filename = request.args["file"][0].decode('utf-8', 'ignore').encode('utf-8')
-			filename = re.sub("^/+", "/", os.path.realpath(filename))
+			filename = lenient_force_utf_8(request.args["file"][0])
+			filename = sanitise_filename_slashes(os.path.realpath(filename))
 
 			if not os.path.exists(filename):
 				return "File '%s' not found" % (filename)

programming_language: Python
filename: rest_fs_access.py
change_type: ModificationType.MODIFY
diff: @@ -43,11 +43,9 @@ import urlparse
 import twisted.web.static
 from twisted.web import http
 
+from utilities import MANY_SLASHES_REGEX
 import file
 
-MANY_SLASHES_PATTERN = r'[\/]+'
-MANY_SLASHES_REGEX = re.compile(MANY_SLASHES_PATTERN)
-
 #: default path from which files will be served
 DEFAULT_ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
 

programming_language: Python