CVE-2022-39298: Deserialization of Untrusted Data (CWE-502)
value: MelisFront is the engine that displays website hosted on Melis Platform. It deals with showing pages, plugins, URL rewritting, search optimization and SEO, etc. Attackers can deserialize arbitrary data on affected versions of `melisplatform/melis-front`, and ultimately leads to the execution of arbitrary PHP code on the system. Conducting this attack does not require authentication. Users should immediately upgrade to `melisplatform/melis-front` >= 5.0.1. This issue was addressed by restricting allowed classes when deserializing user-controlled data.
CWE description: The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
CVSS v3 base score: 9.8
Published: 2022-10-12T23:15Z
Repository: https://github.com/melisplatform/melis-front
Language: PHP
Files changed: src/Controller/MelisPluginRendererController.php, src/Navigation/MelisFrontNavigation.php, src/Service/MelisSiteConfigService.php
Commit date: 2022-09-26 16:25:57 +0800
Commit message: added allowed_classes=false param to unserialize function and changed interop container to psr container

Diff: diff --git a/src/Controller/MelisPluginRendererController.php b/src/Controller/MelisPluginRendererController.php
index 1ccf053..92ceea0 100644
--- a/src/Controller/MelisPluginRendererController.php
+++ b/src/Controller/MelisPluginRendererController.php
@@ -30,11 +30,11 @@ class MelisPluginRendererController extends MelisAbstractActionController
         if (!empty($post['pluginHardcodedConfig']))
         {
             $pluginHardcodedConfig = $post['pluginHardcodedConfig'];
             $pluginHardcodedConfig = html_entity_decode($pluginHardcodedConfig, ENT_QUOTES);
             $pluginHardcodedConfig = html_entity_decode($pluginHardcodedConfig, ENT_QUOTES);
-            $pluginHardcodedConfig = unserialize($pluginHardcodedConfig);
+            $pluginHardcodedConfig = unserialize($pluginHardcodedConfig, ['allowed_classes' => false]);
         }
         
         $translator = $this->getServiceManager()->get('translator');
     
         $results = array();
diff --git a/src/Navigation/MelisFrontNavigation.php b/src/Navigation/MelisFrontNavigation.php
index 32e5769..08c5b23 100644
--- a/src/Navigation/MelisFrontNavigation.php
+++ b/src/Navigation/MelisFrontNavigation.php
@@ -8,11 +8,11 @@
  */
 
 namespace MelisFront\Navigation;
 
 use Laminas\Navigation\Service\DefaultNavigationFactory;
-use Interop\Container\ContainerInterface;
+use Psr\Container\ContainerInterface;
 use Laminas\ServiceManager\ServiceManager;
 use Laminas\EventManager\EventManager;
 use Laminas\EventManager\EventManagerInterface;
 
 /**
diff --git a/src/Service/MelisSiteConfigService.php b/src/Service/MelisSiteConfigService.php
index 8d5c43d..970f9b2 100644
--- a/src/Service/MelisSiteConfigService.php
+++ b/src/Service/MelisSiteConfigService.php
@@ -246,22 +246,22 @@ class MelisSiteConfigService extends MelisGeneralService
                             if ($dbConf['sconf_lang_id'] == '-1') {
                                 $siteConfig = ArrayUtils::merge(
                                     $siteConfig,
                                     [
                                         'site' => [
-                                            $siteName => unserialize($dbConf['sconf_datas'])
+                                            $siteName => unserialize($dbConf['sconf_datas'], ['allowed_classes' => false])
                                         ],
                                     ],
                                     true
                                 );
                             } else {
                                 $siteConfig = ArrayUtils::merge(
                                     $siteConfig,
                                     [
                                         'site' => [
                                             $siteName => [
-                                                $siteId => unserialize($dbConf['sconf_datas'])
+                                                $siteId => unserialize($dbConf['sconf_datas'], ['allowed_classes' => false])
                                             ],
                                         ]
                                     ],
                                     true
                                 );

Vulnerable code:             $pluginHardcodedConfig = unserialize($pluginHardcodedConfig);
use Interop\Container\ContainerInterface;
                                            $siteName => unserialize($dbConf['sconf_datas'])
                                                $siteId => unserialize($dbConf['sconf_datas'])
Fixed code:             $pluginHardcodedConfig = unserialize($pluginHardcodedConfig, ['allowed_classes' => false]);
use Psr\Container\ContainerInterface;
                                            $siteName => unserialize($dbConf['sconf_datas'], ['allowed_classes' => false])
                                                $siteId => unserialize($dbConf['sconf_datas'], ['allowed_classes' => false])