CVE-2023-38708 (published 2023-08-04T01:15Z)

Pimcore is an Open Source Data & Experience Management Platform: PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce. A path traversal vulnerability exists in the `AssetController::importServerFilesAction`, which allows an attacker to overwrite or modify sensitive files by manipulating the pimcore_log parameter.This can lead to potential denial of service---key file overwrite.\nThe impact of this vulnerability allows attackers to: overwrite or modify sensitive files, potentially leading to unauthorized access, privilege escalation, or disclosure of confidential information. This could also cause a denial of service (DoS) if critical system files are overwritten or deleted.

CVSS v3 base score: 8.8, HIGH (CVSS:3.1/AV:N/AC:L/PR:L/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/pimcore/pimcore
commit_details: repo_url: https://github.com/pimcore/pimcore
author: TobiSw61
author_date: 2023-08-03 09:04:46+02:00
msg: Fix import server files dir traversal (#15664)

* Fix import server files action to prevent directory traversal

* Fix import server files action to prevent directory traversal

* Fix import server files action to prevent directory traversal

- adjust code comment

* Fix import server files action to prevent directory traversal

- remove not needed string manipulation check of serverPath as it is already checked before
repository: repo_url: https://github.com/pimcore/pimcore
repo_name: pimcore/pimcore
description: Core Framework for the Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)
repo_language: PHP
owner: pimcore
file_changes: filename: AssetController.php
change_type: ModificationType.MODIFY
diff: @@ -2477,6 +2477,14 @@ class AssetController extends ElementControllerBase implements KernelControllerE
 
         $files = explode('::', $request->get('files'));
 
+        // prevent directory traversal
+        foreach ($files as $file) {
+            $absolutePath = realpath($serverPath.$file);
+            if (!str_starts_with($absolutePath, $serverPath)) {
+                throw $this->createAccessDeniedException('Please do not navigate out of the web root directory!');
+            }
+        }
+
         foreach ($files as $file) {
             $absolutePath = $serverPath . $file;
             $this->checkForPharStreamWrapper($absolutePath);

programming_language: PHP