Skip to content

Commit

Permalink
Prevent information disclosure through incorrect access control in th…
Browse files Browse the repository at this point in the history
…e back end (see CVE-2018-20028)
  • Loading branch information
leofeyer committed Dec 13, 2018
1 parent e30def2 commit e073d0c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
11 changes: 10 additions & 1 deletion src/Resources/contao/dca/tl_article.php
Expand Up @@ -376,7 +376,16 @@ public function checkPermission()
$GLOBALS['TL_DCA']['tl_page']['fields']['cgroup']['default'] = (int) Config::get('defaultGroup') ?: (int) $this->User->groups[0];

// Restrict the page tree
$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $this->User->pagemounts;
if (empty($this->User->pagemounts) || !\is_array($this->User->pagemounts))
{
$root = array(0);
}
else
{
$root = $this->User->pagemounts;
}

$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $root;

// Set allowed page IDs (edit multiple)
if (\is_array($session['CURRENT']['IDS']))
Expand Down
5 changes: 1 addition & 4 deletions src/Resources/contao/dca/tl_content.php
Expand Up @@ -888,11 +888,8 @@ public function checkPermission()
// Check the current action
switch (Input::get('act'))
{
case 'paste':
// Allow
break;

case '': // empty
case 'paste':
case 'create':
case 'select':
// Check access to the article
Expand Down
7 changes: 5 additions & 2 deletions src/Resources/contao/dca/tl_form_field.php
Expand Up @@ -462,11 +462,14 @@ public function checkPermission()
switch (Input::get('act'))
{
case 'paste':
// Allow
case 'select':
if (!\in_array($id, $root))
{
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to access form ID ' . $id . '.');
}
break;

case 'create':
case 'select':
if (!\strlen(Input::get('id')) || !\in_array(Input::get('id'), $root))
{
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to access form ID ' . Input::get('id') . '.');
Expand Down
11 changes: 10 additions & 1 deletion src/Resources/contao/dca/tl_page.php
Expand Up @@ -713,7 +713,16 @@ public function checkPermission()
$GLOBALS['TL_DCA']['tl_page']['fields']['cgroup']['default'] = (int) Config::get('defaultGroup') ?: (int) $this->User->groups[0];

// Restrict the page tree
$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $this->User->pagemounts;
if (empty($this->User->pagemounts) || !\is_array($this->User->pagemounts))
{
$root = array(0);
}
else
{
$root = $this->User->pagemounts;
}

$GLOBALS['TL_DCA']['tl_page']['list']['sorting']['root'] = $root;

// Set allowed page IDs (edit multiple)
if (\is_array($session['CURRENT']['IDS']))
Expand Down
17 changes: 16 additions & 1 deletion src/Resources/contao/drivers/DC_Table.php
Expand Up @@ -229,7 +229,14 @@ public function __construct($strTable, $arrModule=array())
// Get root records from global configuration file
elseif (\is_array($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']))
{
$this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table));
if ($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] == array(0))
{
$this->root = array(0);
}
else
{
$this->root = $this->eliminateNestedPages($GLOBALS['TL_DCA'][$table]['list']['sorting']['root'], $table, $this->Database->fieldExists('sorting', $table));
}
}
}

Expand Down Expand Up @@ -5522,6 +5529,14 @@ protected function filterMenu($intFilterPanel)
}
}

$table = ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 6) ? $this->ptable : $this->strTable;

// Limit the options if there are root records
if (isset($GLOBALS['TL_DCA'][$table]['list']['sorting']['root']) && $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'] !== false)
{
$arrProcedure[] = "id IN(" . implode(',', array_map('\intval', $GLOBALS['TL_DCA'][$table]['list']['sorting']['root'])) . ")";
}

$objFields = $this->Database->prepare("SELECT DISTINCT " . $what . " FROM " . $this->strTable . ((\is_array($arrProcedure) && \strlen($arrProcedure[0])) ? ' WHERE ' . implode(' AND ', $arrProcedure) : ''))
->execute($arrValues);

Expand Down

0 comments on commit e073d0c

Please sign in to comment.