Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY-20] Fix local file inclusion vulnerability in setup action parameter #13422

Merged
merged 1 commit into from Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup/includes/modinstall.class.php
Expand Up @@ -52,7 +52,7 @@ class modInstall {
*/
function __construct(array $options = array()) {
if (isset ($_REQUEST['action'])) {
$this->action = $_REQUEST['action'];
$this->action = preg_replace('/(\.+\/)+/', '', htmlspecialchars($_REQUEST['action']));
}
if (is_array($options)) {
$this->options = $options;
Expand Down
10 changes: 7 additions & 3 deletions setup/includes/request/modinstallconnectorrequest.class.php
Expand Up @@ -60,15 +60,19 @@ public function loadError($class = 'error.modInstallJSONError',$path = '',array
* @param string $action
*/
public function handle($action = '') {
if (empty($_REQUEST['action'])) $this->error->failure('No processor specified!');
$this->action = $_REQUEST['action'];
if (empty($this->install->action)) {
$this->error->failure('No processor specified!');
}
$this->action = $this->install->action;

if($this->action !== 'database/connection') {
$this->install->loadDriver();
}

$f = MODX_SETUP_PATH . 'processors/' . $this->action . '.php';
if (!file_exists($f)) $this->error->failure('Could not load requested processor for action ' . $this->action . '.');
if (!file_exists($f)) {
$this->error->failure('Could not load requested processor for action ' . $this->action . '.');
}

$install =& $this->install;
$install->loadSettings();
Expand Down
13 changes: 9 additions & 4 deletions setup/includes/request/modinstallrequest.class.php
Expand Up @@ -68,13 +68,18 @@ public function handle() {
$this->install->lexicon->load('drivers');
$this->parser->set('_lang',$this->install->lexicon->fetch());

$this->action= isset ($_REQUEST['action']) ? $_REQUEST['action'] : 'language';
$this->parser->set('action',$this->action);

$this->action= !empty($this->install->action) ? $this->install->action : 'language';
$this->parser->set('action',$this->install->action);

$output = $this->parser->fetch('header.tpl');
$parser =& $this->parser;
$output .= include MODX_SETUP_PATH . 'controllers/' . $this->action . '.php';
$actionFile = MODX_SETUP_PATH . 'controllers/' . $this->action . '.php';
if (file_exists($actionFile)) {
$output .= include $actionFile;
}
else {
$output .= '<h1>Error</h1><p>Action not found.</p>';
}
$output .= $this->parser->fetch('footer.tpl');

return $output;
Expand Down