CVE-2020-29006 (published 2020-11-24T15:15Z)

MISP before 2.4.135 lacks an ACL check, related to app/Controller/GalaxyElementsController.php and app/Model/GalaxyElement.php.

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

Weakness information:
cwe_id: CWE-862
cwe_name: Missing Authorization
description: The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
extended_description: 
            Assuming a user with a given identity, authorization is the process of determining whether that user can access a given resource, based on the user's privileges and any permissions or other access-control specifications that apply to the resource.
            When access control checks are not applied, users are able to access data or perform actions that they should not be allowed to perform. This can lead to a wide range of problems, including information exposures, denial of service, and arbitrary code execution.
         
         

Fix information:
repo_url: https://github.com/MISP/MISP
commit_details: repo_url: https://github.com/MISP/MISP
author: mokaddem
author_date: 2020-11-24 12:15:42+01:00
msg: fix: [security] Make cluster's elements adhere to ACL
repository: repo_url: https://github.com/MISP/MISP
repo_name: MISP/MISP
description: MISP (core software) - Open Source Threat Intelligence and Sharing Platform
repo_language: PHP
owner: MISP
file_changes: filename: GalaxyElementsController.php
change_type: ModificationType.MODIFY
diff: @@ -14,9 +14,11 @@ class GalaxyElementsController extends AppController
             )
     );
 
-    public function index($id)
+    public function index($clusterId)
     {
-        $this->paginate['conditions'] = array('GalaxyElement.galaxy_cluster_id' => $id);
+        $aclConditions = $this->GalaxyElement->buildClusterConditions($this->Auth->user(), $clusterId);
+        $this->paginate['conditions'] = [$aclConditions];
+        $this->paginate['contain'] = ['GalaxyCluster' => ['fields' => ['id', 'distribution', 'org_id']]];
         $clusters = $this->paginate();
         $this->set('list', $clusters);
         if ($this->request->is('ajax')) {

programming_language: PHP
filename: GalaxyElement.php
change_type: ModificationType.MODIFY
diff: @@ -95,4 +95,37 @@ class GalaxyElement extends AppModel
         }
         $this->saveMany($tempElements);
     }
+
+    public function buildACLConditions($user)
+    {
+        $conditions = [];
+        if (!$user['Role']['perm_site_admin']) {
+            $conditions = $this->GalaxyCluster->buildConditions($user);
+        }
+        return $conditions;
+    }
+
+    public function buildClusterConditions($user, $clusterId)
+    {
+        return [
+            $this->buildACLConditions($user),
+            'GalaxyCluster.id' => $clusterId
+        ];
+    }
+
+    public function fetchElements(array $user, $clusterId)
+    {
+        $params = array(
+            'conditions' => $this->buildClusterConditions($user, $clusterId),
+            'contain' => ['GalaxyCluster' => ['fields' => ['id', 'distribution', 'org_id']]],
+            'recursive' => -1
+        );
+        $elements = $this->find('all', $params);
+        foreach ($elements as $i => $element) {
+            $elements[$i] = $elements[$i]['GalaxyElement'];
+            unset($elements[$i]['GalaxyCluster']);
+            unset($elements[$i]['GalaxyElement']);
+        }
+        return $elements;
+    }
 }

programming_language: PHP