Skip to content

Commit

Permalink
SEC Add a protection against installation of external module bypassing
Browse files Browse the repository at this point in the history
installmodules.lock
  • Loading branch information
eldy committed Apr 4, 2024
1 parent e27cf04 commit c24bbe2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions htdocs/admin/modules.php
Expand Up @@ -123,6 +123,13 @@
@ini_set("max_execution_time", $max_execution_time_for_deploy); // This work only if safe mode is off. also web servers has timeout of 300
}

$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
$allowonlineinstall = true;
$allowfromweb = 1;
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
$allowonlineinstall = false;
}


/*
* Actions
Expand All @@ -143,7 +150,7 @@
$search_version = '';
}

if ($action == 'install') {
if ($action == 'install' && $allowonlineinstall) {
$error = 0;

// $original_file should match format module_modulename-x.y[.z].zip
Expand Down Expand Up @@ -264,6 +271,8 @@
if (!$error) {
setEventMessages($langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")), null, 'warnings');
}
} elseif ($action == 'install' && !$allowonlineinstall) {
httponly_accessforbidden("You try to bypass the protection to disallow deployment of an external module. Hack attempt ?");
}

if ($action == 'set' && $user->admin) {
Expand Down Expand Up @@ -1191,13 +1200,6 @@
if ($mode == 'deploy') {
print dol_get_fiche_head($head, $mode, '', -1);

$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
$allowonlineinstall = true;
$allowfromweb = 1;
if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
$allowonlineinstall = false;
}

$fullurl = '<a href="'.$urldolibarrmodules.'" target="_blank" rel="noopener noreferrer">'.$urldolibarrmodules.'</a>';
$message = '';
if ($allowonlineinstall) {
Expand Down

0 comments on commit c24bbe2

Please sign in to comment.