CVE-2016-7565 (published 2017-02-13T18:59Z)

install/index.php in Exponent CMS 2.3.9 allows remote attackers to execute arbitrary commands via shell metacharacters in the sc array parameter.

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.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-284
cwe_name: Improper Access Control
description: The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
extended_description: 
            Access control involves the use of several protection mechanisms such as:
            
               Authentication (proving the identity of an actor)
               Authorization (ensuring that a given actor can access a resource), and
               Accountability (tracking of activities that were performed)
            
            When any mechanism is not applied or otherwise fails, attackers can compromise the security of the product by gaining privileges, reading sensitive information, executing commands, evading detection, etc.
            There are two distinct behaviors that can introduce access control weaknesses:
               
                  Specification: incorrect privileges, permissions, ownership, etc. are explicitly specified for either the user or the resource (for example, setting a password file to be world-writable, or giving administrator capabilities to a guest user). This action could be performed by the program or the administrator.
                  Enforcement: the mechanism contains errors that prevent it from properly enforcing the specified access control requirements (e.g., allowing the user to specify their own privileges, or allowing a syntactically-incorrect ACL to produce insecure settings). This problem occurs within the program itself, in that it does not actually enforce the intended security policy that the administrator specifies.
               
         
		 

Fix information:
repo_url: https://github.com/exponentcms/exponent-cms
commit_details: repo_url: https://github.com/exponentcms/exponent-cms
author: dleffler
author_date: 2016-09-21 21:00:30-04:00
msg: security fix to prevent possible hacking by moving security checks earlier in the install code
repository: repo_url: https://github.com/exponentcms/exponent-cms
repo_name: exponentcms/exponent-cms
description: Content Management, Simple.
repo_language: PHP
owner: exponentcms
file_changes: filename: index.php
change_type: ModificationType.MODIFY
diff: @@ -29,7 +29,6 @@ if (version_compare(PHP_VERSION, '5.3.1', 'lt')) {
 
 ob_start();
 
-
 // Jumpstart to Initialize the installer language before it's set to default
 if (isset($_REQUEST['lang'])) {
     $_REQUEST['sc']['LANGUAGE'] = trim($_REQUEST['lang'], "'");
@@ -43,6 +42,27 @@ if (isset($_REQUEST['sc']['LANGUAGE'])) {
 include_once('../exponent.php');
 expString::sanitize($_REQUEST);
 
+// Make sure our 'page' is set correctly and prevent running under most circumstances
+if (file_exists("../framework/conf/config.php") && !isset($_REQUEST['page'])) {
+    $_REQUEST['page'] = 'upgrade-1';
+}
+if (!file_exists("../framework/conf/config.php") && !isset($_REQUEST['page'])) {
+    $_REQUEST['page'] = 'welcome';
+}
+$page = $_REQUEST['page'];
+
+// Superadmin must be logged in to do an upgrade
+if (strpos($page, 'upgrade-') !== false && empty($user->isSuperAdmin())) {
+    header('Location: ../index.php');
+    exit();
+}
+
+// Only run installation if not already installed
+if (strpos($page, 'upgrade-') === false && !file_exists(BASE . 'install/not_configured')) {
+    header('Location: ../index.php');
+    exit();
+}
+
 // Switch to a saved profile as requested
 if (isset($_REQUEST['profile'])) {
     expSettings::activateProfile($_REQUEST['profile']);
@@ -57,13 +77,11 @@ if (isset($_REQUEST['sc'])) {
     if (file_exists("../framework/conf/config.php")) {
         // Update the config
         foreach ($_REQUEST['sc'] as $key => $value) {
-//            $value = expString::sanitize($value);
             expSettings::change($key, $value);
         }
     } else {
         // Initialize /framework/conf/config
         $values = array(
-//            'c'          => expString::sanitize($_REQUEST['sc']),
             'c'          => $_REQUEST['sc'],
             'opts'       => array(),
             'configname' => 'Default',
@@ -75,6 +93,10 @@ if (isset($_REQUEST['sc'])) {
 
 // Install a sample database as requested
 if (isset($_REQUEST['install_sample'])) {
+    if (!empty($_REQUEST['install_sample']) && (strpos($_REQUEST['install_sample'], '..') !== false || strpos($_REQUEST['install_sample'], '/') !== false)) {
+        header('Location: ../index.php');
+        exit();  // attempt to hack the site
+    }
     $eql = BASE . "themes/" . DISPLAY_THEME_REAL . "/" . $_REQUEST['install_sample'] . ".eql";
     if (!file_exists($eql)) {
         $eql = BASE . "install/samples/" . $_REQUEST['install_sample'] . ".eql";
@@ -104,27 +126,6 @@ if (isset($_REQUEST['install_sample'])) {
     }
 }
 
-// Make sure our 'page' is set correctly
-if (file_exists("../framework/conf/config.php") && !isset($_REQUEST['page'])) {
-    $_REQUEST['page'] = 'upgrade-1';
-}
-if (!file_exists("../framework/conf/config.php") && !isset($_REQUEST['page'])) {
-    $_REQUEST['page'] = 'welcome';
-}
-$page = $_REQUEST['page'];
-
-// Superadmin must be logged in to do an upgrade
-if (strpos($page, 'upgrade-') !== false && empty($user->is_admin)) {
-    header('Location: ../index.php');
-    exit();
-}
-
-// Only run installation if not already installed
-if (strpos($page, 'upgrade-') === false && !file_exists(BASE . 'install/not_configured')) {
-    header('Location: ../index.php');
-    exit();
-}
-
 switch ($page) {
     case 'upgrade-1':
         $masthead = gt("Upgrade");
@@ -271,4 +272,4 @@ switch ($page) {
     </html>
 <?php
 ob_end_flush();
-?>
\ No newline at end of file
+?>

programming_language: PHP