https://github.com/Cacti/cacti/issues/4019 From ef10fe1c340ed932dc18b6a566b21f9dd15933c2 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 23 Dec 2020 16:33:27 -0500 Subject: [PATCH] Fixing Issue #4019 * In a recent audit of core Cacti code, there were a few stored XSS issues that can be exposed * Also removed a few spurious title_trims, that should no longer be a problem. --- a/automation_devices.php +++ b/automation_devices.php @@ -485,7 +485,7 @@ function draw_filter() { $name) { - print ""; + print ""; } } ?> @@ -515,7 +515,7 @@ function draw_filter() { ' . $st . ""; + print ""; } } ?> @@ -530,7 +530,7 @@ function draw_filter() { ' . $st . ""; + print ""; } } ?> @@ -545,7 +545,7 @@ function draw_filter() { ' . $st . ""; + print ""; } } ?> @@ -560,7 +560,7 @@ function draw_filter() { 0) { foreach ($item_rows as $key => $value) { - print ""; + print ""; } } ?> --- a/data_debug.php +++ b/data_debug.php @@ -969,7 +969,7 @@ function data_debug_filter() { if (cacti_sizeof($templates) > 0) { foreach ($templates as $template) { - print ""; + print "'; } } ?> @@ -997,7 +997,7 @@ function data_debug_filter() { $profiles = array_rekey(db_fetch_assoc('SELECT id, name FROM data_source_profiles ORDER BY name'), 'id', 'name'); if (cacti_sizeof($profiles)) { foreach ($profiles as $key => $value) { - print ""; + print "'; } } ?> @@ -1063,7 +1063,7 @@ function data_debug_filter() { 0) { foreach ($item_rows as $key => $value) { - print ""; + print "'; } } ?> --- a/data_sources.php +++ b/data_sources.php @@ -1361,7 +1361,7 @@ function clearFilter() { if (cacti_sizeof($templates)) { foreach ($templates as $template) { - print "'; + print "'; } } ?> --- a/lib/api_automation.php +++ b/lib/api_automation.php @@ -154,7 +154,7 @@ function clearDeviceFilter() { if (cacti_sizeof($host_templates)) { foreach ($host_templates as $host_template) { - print "\n"; + print "'; } } ?> @@ -184,7 +184,7 @@ function clearDeviceFilter() { $value) { - print "\n'; + print "'; } } ?> @@ -432,7 +432,7 @@ function clearFilter() { $hosts = get_allowed_devices(); if (cacti_sizeof($hosts)) { foreach ($hosts as $host) { - print "\n"; + print "'; } } ?> @@ -453,7 +453,7 @@ function clearFilter() { if (cacti_sizeof($templates) > 0) { foreach ($templates as $template) { - print "\n"; + print "'; } } ?> @@ -484,7 +484,7 @@ function clearFilter() { $value) { - print "\n"; + print "'; } } ?> @@ -718,7 +718,7 @@ function clearObjectFilter() { $value) { - print "\n'; + print "'; } } ?> @@ -1078,10 +1078,10 @@ function clearFilter() { 0) { - foreach ($host_templates as $host_template) { - print "\n"; - } + if (cacti_sizeof($host_templates)) { + foreach ($host_templates as $host_template) { + print "'; + } } ?> @@ -1110,7 +1110,7 @@ function clearFilter() { $value) { - print "\n"; + print "'; } } ?> --- a/lib/html.php +++ b/lib/html.php @@ -998,7 +998,7 @@ function html_create_list($form_data, $column_display, $column_id, $form_previou print ' selected'; } - print '>' . title_trim(null_out_substitutions(html_escape($form_data[$id])), 75) . ''; + print '>' . html_escape(null_out_substitutions($form_data[$id])) . ''; } } } else { @@ -1011,9 +1011,9 @@ function html_create_list($form_data, $column_display, $column_id, $form_previou } if (isset($row['host_id'])) { - print '>' . title_trim(html_escape($row[$column_display]), 75) . ''; + print '>' . html_escape($row[$column_display]) . ''; } else { - print '>' . title_trim(null_out_substitutions(html_escape($row[$column_display])), 75) . ''; + print '>' . html_escape(null_out_substitutions($row[$column_display])) . ''; } } } @@ -2010,7 +2010,7 @@ function html_host_filter($host_id = '-1', $call_back = 'applyFilter', $sql_wher if (cacti_sizeof($devices)) { foreach ($devices as $device) { - print "'; + print "'; } } ?> @@ -2385,6 +2385,7 @@ function html_common_header($title, $selectedTheme = '') { + <?php print $title; ?> --- a/lib/html_graph.php +++ b/lib/html_graph.php @@ -212,9 +212,9 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat @@ -260,7 +260,7 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat if (cacti_sizeof($graph_timespans)) { foreach($graph_timespans as $value => $text) { - print "\n"; + print "'; } } ?> @@ -293,7 +293,7 @@ function html_graph_preview_filter($page, $action, $devices_where = '', $templat $end_val = cacti_sizeof($graph_timeshifts)+1; if (cacti_sizeof($graph_timeshifts) > 0) { for ($shift_value=$start_val; $shift_value < $end_val; $shift_value++) { - print "\n"; + print "'; } } ?> --- a/lib/html_tree.php +++ b/lib/html_tree.php @@ -1138,7 +1138,7 @@ function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data) { if (cacti_sizeof($graph_timespans)) { foreach($graph_timespans as $value => $text) { - print "'; + print "'; } } ?> @@ -1171,7 +1171,7 @@ function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data) { $end_val = cacti_sizeof($graph_timeshifts)+1; if (cacti_sizeof($graph_timeshifts)) { for ($shift_value=$start_val; $shift_value < $end_val; $shift_value++) { - print "'; + print "'; } } ?> --- a/managers.php +++ b/managers.php @@ -483,7 +483,7 @@ function clearFilter() { ' . $mib['mib'] . ''; + print "'; } } ?> --- a/utilities.php +++ b/utilities.php @@ -812,7 +812,7 @@ function applyFilter() { if (cacti_sizeof($users)) { foreach ($users as $user) { - print "'; + print "'; } } ?> @@ -1034,19 +1034,19 @@ function utilities_view_logfile() { $logfile = basename(get_nfilter_request_var('filename')); $logbase = basename(read_config_option('path_cactilog')); - + if ($logfile == '') { $logfile = $logbase; } - + if ($logfile == '') { $logfile = 'cacti.log'; } - + $logname = ''; $logpath = ''; - if (!clog_validate_filename($logfile, $logpath, $logname, true)) { + if (!clog_validate_filename($logfile, $logpath, $logname, true)) { raise_message('clog_invalid'); header('Location: utilities.php?action=view_logfile&filename=' . $logbase); exit(0); @@ -1171,7 +1171,7 @@ function clearFilter() { if (cacti_sizeof($logFileArray)) { foreach ($logFileArray as $logFile) { - print "'; + print '>' . html_escape($logName . ($logDate != '' ? ' [' . substr($logDate,4) . ']':'')) . ''; } } ?> @@ -1807,7 +1807,7 @@ function clearFilter() { if (cacti_sizeof($templates)) { foreach ($templates as $template) { - print "'; + print "'; } } ?> @@ -2540,7 +2540,7 @@ function clearFilter() { 0) { foreach ($mibs as $mib) { - print "'; + print "'; } } ?> @@ -2804,7 +2804,7 @@ function purgeFilter() { ' . $receiver['hostname'] . ''; + print "'; } ?>