CVE-2019-10867 (published 2019-04-04T18:29Z)

An issue was discovered in Pimcore before 5.7.1. An attacker with classes permission can send a POST request to /admin/class/bulk-commit, which will make it possible to exploit the unserialize function when passing untrusted values in the data parameter to bundles/AdminBundle/Controller/Admin/DataObject/ClassController.php.

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

Weakness information:
cwe_id: CWE-502
cwe_name: Deserialization of Untrusted Data
description: The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
extended_description: 
            It is often convenient to serialize objects for communication or to save them for later use. However, deserialized data or code can often be modified without using the provided accessor functions if it does not use cryptography to protect itself. Furthermore, any cryptography would still be client-side security -- which is a dangerous security assumption.
            Data that is untrusted can not be trusted to be well-formed.
            When developers place no restrictions on "gadget chains," or series of instances and method invocations that can self-execute during the deserialization process (i.e., before the object is returned to the caller), it is sometimes possible for attackers to leverage them to perform unauthorized actions, like generating a shell.
         
         

Fix information:
repo_url: https://github.com/pimcore/pimcore
commit_details: repo_url: https://github.com/pimcore/pimcore
author: Bernhard Rusch
author_date: 2019-03-19 15:58:50+01:00
msg: [Object] optimized bulk import
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: ClassController.php
change_type: ModificationType.MODIFY
diff: @@ -24,9 +24,11 @@ use Pimcore\Model;
 use Pimcore\Model\Asset;
 use Pimcore\Model\DataObject;
 use Pimcore\Model\Document;
+use Pimcore\Tool\Session;
 use Symfony\Component\EventDispatcher\GenericEvent;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface;
 use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
 use Symfony\Component\Routing\Annotation\Route;
@@ -1347,9 +1349,13 @@ class ClassController extends AdminController implements EventedControllerInterf
         $tmpName = $_FILES['Filedata']['tmp_name'];
         $json = file_get_contents($tmpName);
 
-        $tmpName = PIMCORE_SYSTEM_TEMP_DIRECTORY . '/bulk-import.tmp';
+        $tmpName = PIMCORE_SYSTEM_TEMP_DIRECTORY . '/bulk-import-' . uniqid() . '.tmp';
         file_put_contents($tmpName, $json);
 
+        Session::useSession(function (AttributeBagInterface $session) use ($tmpName) {
+            $session->set('class_bulk_import_file', $tmpName);
+        }, 'pimcore_objects');
+
         $json = json_decode($json, true);
 
         foreach ($json as $groupName => $group) {
@@ -1363,7 +1369,7 @@ class ClassController extends AdminController implements EventedControllerInterf
                     $className = $groupItem['className'];
 
                     $layoutData = ['className' => $className, 'name' => $groupItem['name']];
-                    $name = serialize($layoutData);
+                    $name = json_encode($layoutData);
                     $displayName = $className . ' / ' . $groupItem['name'];
                     $icon = 'database_lightning';
                 } else {
@@ -1382,7 +1388,7 @@ class ClassController extends AdminController implements EventedControllerInterf
             }
         }
 
-        $response = $this->adminJson(['success' => true, 'filename' => $tmpName, 'data' => $result]);
+        $response = $this->adminJson(['success' => true, 'data' => $result]);
         $response->headers->set('Content-Type', 'text/html');
 
         return $response;
@@ -1404,9 +1410,10 @@ class ClassController extends AdminController implements EventedControllerInterf
      */
     public function bulkCommitAction(Request $request)
     {
-        $filename = $request->get('filename');
         $data = json_decode($request->get('data'), true);
 
+        $session = Session::get('pimcore_objects');
+        $filename = $session->get('class_bulk_import_file');
         $json = @file_get_contents($filename);
         $json = json_decode($json, true);
 
@@ -1451,7 +1458,7 @@ class ClassController extends AdminController implements EventedControllerInterf
 
                 return $this->adminJson(['success' => $success !== false]);
             } elseif ($type == 'customlayout') {
-                $layoutData = unserialize($data['name']);
+                $layoutData = json_decode($data['name'], true);
                 $className = $layoutData['className'];
                 $layoutName = $layoutData['name'];
 

programming_language: PHP