CVE-2023-30852: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (CWE-22)
value: Pimcore is an open source data and experience management platform. Prior to version 10.5.21, the `/admin/misc/script-proxy` API endpoint that is accessible by an authenticated administrator user is vulnerable to arbitrary JavaScript and CSS file read via the `scriptPath` and `scripts` parameters. The `scriptPath` parameter is not sanitized properly and is vulnerable to path traversal attack. Any JavaScript/CSS file from the application server can be read by specifying sufficient number of `../` patterns to go out from the application webroot followed by path of the folder where the file is located in the "scriptPath" parameter and the file name in the "scripts" parameter. The JavaScript file is successfully read only if the web application has read access to it. Users should update to version 10.5.21 to receive a patch or, as a workaround, apply the patch manual.
CWE 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.
CVSS v3 base score: 4.9
Published: 2023-04-27T17:15Z
Repository: https://github.com/pimcore/pimcore
Language: PHP
Files changed: bundles/AdminBundle/Controller/Admin/Asset/AssetController.php, bundles/AdminBundle/Resources/public/js/pimcore/asset/tree.js, doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
Commit date: 2023-04-20 16:56:53 +0200
Commit message: [Security] Admin Authenticated Arbitrary File Read (#14974)

* Fix: disable asset importFromServer for users

* Doc: Add Upgrade Notes
Diff: diff --git a/bundles/AdminBundle/Controller/Admin/Asset/AssetController.php b/bundles/AdminBundle/Controller/Admin/Asset/AssetController.php
index c2a6a90b244e..f3ec571ee625 100644
--- a/bundles/AdminBundle/Controller/Admin/Asset/AssetController.php
+++ b/bundles/AdminBundle/Controller/Admin/Asset/AssetController.php
@@ -2457,10 +2457,14 @@ class AssetController extends ElementControllerBase implements KernelControllerE
      *
      * @return JsonResponse
      */
     public function importServerFilesAction(Request $request)
     {
+        if(!Tool\Admin::getCurrentUser()->isAdmin()) {
+            throw $this->createAccessDeniedException('Permission denied. You don\'t have the rights to import files from the server!');
+        }
+
         $assetFolder = Asset::getById((int) $request->get('parentId'));
         if (!$assetFolder) {
             throw $this->createNotFoundException('Parent asset not found');
         }
 
diff --git a/bundles/AdminBundle/Resources/public/js/pimcore/asset/tree.js b/bundles/AdminBundle/Resources/public/js/pimcore/asset/tree.js
index 29072edae4bf..6ad46d37747f 100644
--- a/bundles/AdminBundle/Resources/public/js/pimcore/asset/tree.js
+++ b/bundles/AdminBundle/Resources/public/js/pimcore/asset/tree.js
@@ -592,11 +592,11 @@ pimcore.asset.tree = Class.create({
                                 handler: this.uploadZip.bind(this, tree, record),
                                 iconCls: "pimcore_icon_zip pimcore_icon_overlay_upload"
                             });
                         }
 
-                        if (perspectiveCfg.inTreeContextMenu("asset.add.importFromServer")) {
+                        if (perspectiveCfg.inTreeContextMenu("asset.add.importFromServer") && pimcore.currentuser.admin) {
                             menuItems.push({
                                 text: t("import_from_server"),
                                 handler: this.importFromServer.bind(this, tree, record),
                                 iconCls: "pimcore_icon_import_server"
                             });
diff --git a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
index 37c474f30767..3a870e9a7932 100644
--- a/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
+++ b/doc/Development_Documentation/23_Installation_and_Upgrade/09_Upgrade_Notes/README.md
@@ -1,10 +1,14 @@
 # Upgrade Notes
 
+## 10.5.21
+- [Assets] The Asset `Import from Server` feature is now only available for admins. It will be removed in Pimcore 11
+
 ## 10.5.13
 - [Web2Print] Print document twig expressions are now executed in a sandbox with restrictive security policies (just like Sending mails and Dataobject Text Layouts introduced in 10.5.9).
 
+
 ## 10.5.10
 - [DataObject] Deprecated: Loading non-Concrete objects with the Concrete class will not be possible in Pimcore 11.
 
 ## 10.5.9
 - [Twig] Sending mails and Dataobject Text Layouts, which allow rendering user controlled twig templates are now executed in a sandbox with restrictive security policies for tags, filters, functions.

Vulnerable code:                         if (perspectiveCfg.inTreeContextMenu("asset.add.importFromServer")) {
Fixed code:         if(!Tool\Admin::getCurrentUser()->isAdmin()) {
            throw $this->createAccessDeniedException('Permission denied. You don\'t have the rights to import files from the server!');
        }

                        if (perspectiveCfg.inTreeContextMenu("asset.add.importFromServer") && pimcore.currentuser.admin) {
## 10.5.21
- [Assets] The Asset `Import from Server` feature is now only available for admins. It will be removed in Pimcore 11