Skip to content

Commit 0d89b7f

Browse files
authored
Prevent XSSI access to MODx.config by requiring auth token (#15644)
Reported by Solar Security in security report 3837, it's possible to bypass the Same Origin Policy when including the modx.config.js.php connector as a script tag. If a logged-in user is tricked into visiting a malicious site, that would allow the attacker to access information meant for the manager typically available in MODx.config. This information is already filtered to exclude sensitive data like passwords, but may still leak the rest of the MODX configuration including extras. To avoid this XSSI vulnerability, the connector is changed to require permissions the same way as other processors and the manager controller injects the HTTP_MODAUTH URL parameter. Attackers will now need first-party access to the auth token to abuse. To avoid further leaking the auth token, it's only set temporarily while parsing the header.tpl. Should an attacker manage to inject arbitrary smarty tags, that does not provide them the token. Also made sure an error message is returned when the user does not have permission. Custom manager themes that override the header.tpl may require the same fix or break.
1 parent 42b9fb9 commit 0d89b7f

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

connectors/modx.config.js.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,5 @@
1313
* @var modX $modx
1414
*/
1515
define('MODX_CONNECTOR_INCLUDED', 1);
16-
define('MODX_REQP',false);
17-
require_once dirname(__FILE__).'/index.php';
18-
$_SERVER['HTTP_MODAUTH'] = $modx->user->getUserToken($modx->context->get('key'));
16+
require_once __DIR__ .'/index.php';
1917
$modx->request->handleRequest(array('location' => 'system','action' => 'config.js'));

core/model/modx/modmanagercontroller.class.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,11 @@ public function firePreRenderEvents() {}
480480
* @return string
481481
*/
482482
public function getHeader() {
483+
$this->setPlaceholder('_authToken', $this->modx->user->getUserToken('mgr'));
483484
$this->loadController('header.php',true);
484-
return $this->fetchTemplate('header.tpl');
485+
$output = $this->fetchTemplate('header.tpl');
486+
$this->setPlaceholder('_authToken', '');
487+
return $output;
485488
}
486489

487490
/**

core/model/modx/processors/system/config.js.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class modConfigJsProcessor extends modProcessor
2323
public function process()
2424
{
2525
if (!$this->modx->user->isAuthenticated('mgr')) {
26-
return '';
26+
return $this->failure($this->modx->lexicon('permission_denied'));
2727
}
2828
$this->modx->getVersionData();
2929

@@ -33,7 +33,7 @@ public function process()
3333
if ($workingContext instanceof modContext) {
3434
$workingContext->prepare();
3535
} else {
36-
return $this->modx->error->failure($this->modx->error->failure($this->modx->lexicon('permission_denied')));
36+
return $this->modx->error->failure($this->modx->lexicon('permission_denied'));
3737
}
3838
} else {
3939
$workingContext =& $this->modx->context;

manager/templates/default/header.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{/if}
2020
<script src="{$_config.manager_url}assets/modext/core/modx.js?v={$versionToken}"></script>
2121
<script src="{$_config.connectors_url}lang.js.php?ctx=mgr&topic=topmenu,file,resource,trash,{$_lang_topics}&action={$smarty.get.a|default|htmlspecialchars}"></script>
22-
<script src="{$_config.connectors_url}modx.config.js.php?action={$smarty.get.a|default|htmlspecialchars}{if $_ctx}&wctx={$_ctx}{/if}"></script>
22+
<script src="{$_config.connectors_url}modx.config.js.php?action={$smarty.get.a|default|htmlspecialchars}{if $_ctx}&wctx={$_ctx}{/if}&HTTP_MODAUTH={$_authToken|default|htmlspecialchars}"></script>
2323

2424
{$maincssjs}
2525
{foreach from=$cssjs item=scr}

0 commit comments

Comments
 (0)