Skip to content

Commit

Permalink
fix: Fixed command execution for site admins
Browse files Browse the repository at this point in the history
- a server setting allowing the override of the path variable for esoteric RHEL systems allowed site admins to inject arbitrary commands
- impact was limited by the setting being only accessible to the site administrator

- as reported by Michael Grolimund from Swiss Post (@grolinet)
  • Loading branch information
iglocska committed Feb 12, 2018
1 parent 4b30ca6 commit 0a2aa9d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
7 changes: 0 additions & 7 deletions app/Controller/ServersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@ public function startWorker($type) {
$validTypes = array('default', 'email', 'scheduler', 'cache', 'prio');
if (!in_array($type, $validTypes)) throw new MethodNotAllowedException('Invalid worker type.');
$prepend = '';
if (Configure::read('MISP.rh_shell_fix')) $prepend = 'export PATH=$PATH:"/opt/rh/rh-php56/root/usr/bin:/opt/rh/rh-php56/root/usr/sbin"; ';
if ($type != 'scheduler') shell_exec($prepend . APP . 'Console' . DS . 'cake CakeResque.CakeResque start --interval 5 --queue ' . $type .' > /dev/null 2>&1 &');
else shell_exec($prepend . APP . 'Console' . DS . 'cake CakeResque.CakeResque startscheduler -i 5 > /dev/null 2>&1 &');
$this->redirect('/servers/serverSettings/workers');
Expand Down Expand Up @@ -1125,12 +1124,6 @@ public function restartWorkers() {
if (!$this->_isSiteAdmin() || !$this->request->is('post')) throw new MethodNotAllowedException();
$this->Server->workerRemoveDead($this->Auth->user());
$prepend = '';
if (Configure::read('MISP.rh_shell_fix')) {
$prepend = 'export PATH=$PATH:"/opt/rh/rh-php56/root/usr/bin:/opt/rh/rh-php56/root/usr/sbin"; ';
if (Configure::read('MISP.rh_shell_fix_path')) {
if ($this->Server->testForPath(Configure::read('MISP.rh_shell_fix_path'))) $prepend = Configure::read('MISP.rh_shell_fix_path');
}
}
shell_exec($prepend . APP . 'Console' . DS . 'worker' . DS . 'start.sh > /dev/null 2>&1 &');
$this->redirect(array('controller' => 'servers', 'action' => 'serverSettings', 'workers'));
}
Expand Down
18 changes: 0 additions & 18 deletions app/Model/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,24 +695,6 @@ class Server extends AppModel {
'type' => 'numeric',
'null' => false,
),
'rh_shell_fix' => array(
'level' => 1,
'description' => 'If you are running CentOS or RHEL using SCL and are having issues with the Background workers not responding to start/stop/restarts via the worker interface, enable this setting. This will pre-pend the shell execution commands with the default path to rh-php56 (/opt/rh/rh-php56/root/usr/bin:/opt/rh/rh-php56/root/usr/sbin).',
'value' => false,
'errorMessage' => '',
'test' => 'testBool',
'type' => 'boolean',
'null' => true,
),
'rh_shell_fix_path' => array(
'level' => 1,
'description' => 'If you have rh_shell_fix enabled, the default PATH for rh-php56 is added (/opt/rh/rh-php56/root/usr/bin:/opt/rh/rh-php56/root/usr/sbin). If you prefer to use a different path, you can set it here.',
'value' => '/opt/rh/rh-php56/root/usr/bin:/opt/rh/rh-php56/root/usr/sbin',
'errorMessage' => '',
'test' => 'testForPath',
'type' => 'string',
'null' => true,
),
'tmpdir' => array(
'level' => 1,
'description' => 'Please indicate the temp directory you wish to use for certain functionalities in MISP. By default this is set to /tmp and will be used among others to store certain temporary files extracted from imports during the import process.',
Expand Down

0 comments on commit 0a2aa9d

Please sign in to comment.