Skip to content

Commit 4c2ef21

Browse files
Sanitize skin urls that could be used for XSS (#4654)
Co-authored-by: kiatng <[email protected]>
1 parent 5496d8a commit 4c2ef21

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

app/code/core/Mage/Core/Model/Design/Package.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,10 @@ public function getSkinBaseUrl(array $params = [])
359359
{
360360
$params['_type'] = 'skin';
361361
$this->updateParamDefaults($params);
362-
return Mage::getBaseUrl('skin', isset($params['_secure']) ? (bool) $params['_secure'] : null)
363-
. $params['_area'] . '/' . $params['_package'] . '/' . $params['_theme'] . '/';
362+
$urlPath = $params['_area'] . '/' . $params['_package'] . '/' . $params['_theme'] . '/';
363+
// Prevent XSS through malformed configuration
364+
$urlPath = htmlspecialchars($urlPath, ENT_HTML5 | ENT_QUOTES, 'UTF-8');
365+
return Mage::getBaseUrl('skin', isset($params['_secure']) ? (bool) $params['_secure'] : null) . $urlPath;
364366
}
365367

366368
/**
@@ -524,7 +526,8 @@ public function getSkinUrl($file = null, array $params = [])
524526
}
525527
$this->updateParamDefaults($params);
526528
if (!empty($file)) {
527-
$result = $this->_fallback(
529+
// This updates $params with the base package and default theme if the file is not found
530+
$this->_fallback(
528531
$file,
529532
$params,
530533
$this->_fallback->getFallbackScheme(

app/code/core/Mage/Core/etc/system.xml

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@
332332
</template_ua_regexp>
333333
<skin translate="label">
334334
<label>Skin (Images / CSS)</label>
335+
<validate>validate-no-html-tags</validate>
335336
<sort_order>30</sort_order>
336337
<show_in_default>1</show_in_default>
337338
<show_in_website>1</show_in_website>

app/design/adminhtml/default/default/template/oauth/authorize/head-simple.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
var BLANK_URL = '<?php echo $this->getJsUrl() ?>blank.html';
3131
var BLANK_IMG = '<?php echo $this->getJsUrl() ?>spacer.gif';
3232
var BASE_URL = '<?php echo $this->getUrl('*') ?>';
33-
var SKIN_URL = '<?php echo $this->jsQuoteEscape($this->getSkinUrl()) ?>';
33+
var SKIN_URL = '<?php echo $this->getSkinUrl() ?>';
3434
var FORM_KEY = '<?php echo $this->getFormKey() ?>';
3535
//]]>
3636
</script>

app/design/adminhtml/default/default/template/page/head.phtml

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
<link rel="icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon"/>
2222

2323
<script type="text/javascript">
24+
//<![CDATA[
2425
var BLANK_URL = '<?php echo $this->getJsUrl() ?>blank.html';
2526
var BLANK_IMG = '<?php echo $this->getJsUrl() ?>spacer.gif';
2627
var BASE_URL = '<?php echo $this->getUrl('*') ?>';
27-
var SKIN_URL = '<?php echo $this->jsQuoteEscape($this->getSkinUrl()) ?>';
28+
var SKIN_URL = '<?php echo $this->getSkinUrl() ?>';
2829
var FORM_KEY = '<?php echo $this->getFormKey() ?>';
2930
<?php # BC: cast to INT in case of non-existing method getLoadingTimeout() in 3rd-party code?>
3031
var LOADING_TIMEOUT = <?php echo (int)$this->getLoadingTimeout() ?>;
32+
//]]>
3133
</script>
3234

3335
<?php echo $this->getCssJsHtml() ?>

0 commit comments

Comments
 (0)