Skip to content

Commit a07d75d

Browse files
committed
fix(modulesadmin): escape dirname and image at HTML output point
The earlier commit removed early htmlspecialchars() on $dirname to fix the DB lookup bug, but left the img src output point unescaped. If a module dirname or image filename contained quotes or angle brackets, the raw interpolation into the src attribute would be an XSS vector. Escape both $dirname and $module->getInfo('image') at the two HTML output sites (lines 657 and 871 in xoops_module_install and xoops_module_update) using htmlspecialchars() with ENT_QUOTES | ENT_HTML5. The dirname stays raw for all internal operations (DB lookup, filesystem, cache clearing).
1 parent 63e8ba9 commit a07d75d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

htdocs/modules/system/admin/modulesadmin/modulesadmin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ function xoops_module_uninstall($dirname)
654654
$msgs[] = '<div id="xo-module-log"><div class="header">';
655655
$msgs[] = $errs[] = '<h4>' . _AM_SYSTEM_MODULES_UNINSTALL . ' ' . $module->getInfo('name', 's') . '</h4>';
656656
if ($module->getInfo('image') !== false && trim($module->getInfo('image')) != '') {
657-
$msgs[] = '<img src="' . XOOPS_URL . '/modules/' . $dirname . '/' . trim($module->getInfo('image')) . '" alt="" />';
657+
$msgs[] = '<img src="' . XOOPS_URL . '/modules/' . htmlspecialchars($dirname, ENT_QUOTES | ENT_HTML5, 'UTF-8') . '/' . htmlspecialchars(trim($module->getInfo('image')), ENT_QUOTES | ENT_HTML5, 'UTF-8') . '" alt="" />';
658658
}
659659
$msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version');
660660
if ($module->getInfo('author') !== false && trim($module->getInfo('author')) != '') {
@@ -868,7 +868,7 @@ function xoops_module_update($dirname)
868868
$msgs[] = '<div id="xo-module-log"><div class="header">';
869869
$msgs[] = $errs[] = '<h4>' . _AM_SYSTEM_MODULES_UPDATING . $module->getInfo('name', 's') . '</h4>';
870870
if ($module->getInfo('image') !== false && trim($module->getInfo('image')) != '') {
871-
$msgs[] = '<img src="' . XOOPS_URL . '/modules/' . $dirname . '/' . trim($module->getInfo('image')) . '" alt="" />';
871+
$msgs[] = '<img src="' . XOOPS_URL . '/modules/' . htmlspecialchars($dirname, ENT_QUOTES | ENT_HTML5, 'UTF-8') . '/' . htmlspecialchars(trim($module->getInfo('image')), ENT_QUOTES | ENT_HTML5, 'UTF-8') . '" alt="" />';
872872
}
873873
$msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version');
874874
if ($module->getInfo('author') !== false && trim($module->getInfo('author')) != '') {

0 commit comments

Comments
 (0)