diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml
index 7580ee1..76612ac 100644
--- a/.github/workflows/plugin-ci-workflow.yml
+++ b/.github/workflows/plugin-ci-workflow.yml
@@ -187,6 +187,16 @@ jobs:
echo "Syntax errors found!"
exit 1
fi
+
+ - name: Run Plugin Regression Tests
+ run: |
+ cd ${{ github.workspace }}/cacti/plugins/syslog
+ if [ -d tests/regression ]; then
+ for test in tests/regression/*.php; do
+ [ -f "$test" ] || continue
+ php "$test"
+ done
+ fi
- name: Run Cacti Poller
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f1e7f2..7625bff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
--- develop ---
+* issue#252: Harden unescaped syslog UI output paths and remove unsafe HTML string insertion
* issue: Making changes to support Cacti 1.3
* issue: Don't use MyISAM for non-analytical tables
* issue: The install advisor for Syslog was broken in current Cacti releases
diff --git a/js/functions.js b/js/functions.js
index a96d47d..dd6d756 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -220,7 +220,11 @@ function initSyslogMain(config) {
$.each(data, function(index, hostData) {
if ($('#host option[value="'+index+'"]').length == 0) {
- $('#host').append('');
+ var option = $('';
+ print '';
}
}
?>
@@ -541,7 +541,7 @@ function syslog_stats_filter() {
if (cacti_sizeof($facilities)) {
foreach ($facilities as $r) {
- print '\n";
+ print '\n";
}
}
?>
@@ -561,7 +561,7 @@ function syslog_stats_filter() {
if (cacti_sizeof($priorities)) {
foreach ($priorities as $r) {
- print '\n";
+ print '\n";
}
}
?>
@@ -1349,7 +1349,7 @@ function syslog_filter($sql_where, $tab) {
}
}
print '>';
- print $host['host'] . '';
+ print html_escape($host['host']) . '';
}
}
?>
@@ -2037,4 +2037,3 @@ function syslog_form_callback($form_name, $classic_sql, $column_display, $column
' . $removal_info . '';
+ $removal_list .= '
' . html_escape($removal_info) . '';
$removal_array[] = $matches[1];
}
}
@@ -810,4 +810,3 @@ function removal_import() {
header('Location: syslog_removal.php');
}
-
diff --git a/syslog_reports.php b/syslog_reports.php
index f0caec2..bad4022 100644
--- a/syslog_reports.php
+++ b/syslog_reports.php
@@ -157,7 +157,7 @@ function form_actions() {
FROM `' . $syslogdb_default . '`.`syslog_reports`
WHERE id=' . $matches[1]);
- $report_list .= '' . $report_info . '';
+ $report_list .= '' . html_escape($report_info) . '';
$report_array[] = $matches[1];
}
}
@@ -872,4 +872,3 @@ function report_import() {
header('Location: syslog_reports.php');
}
-
diff --git a/tests/regression/issue252_xss_output_test.php b/tests/regression/issue252_xss_output_test.php
new file mode 100644
index 0000000..5833bc8
--- /dev/null
+++ b/tests/regression/issue252_xss_output_test.php
@@ -0,0 +1,45 @@
+')") === false ||
+ strpos($functionsJs, ".text(hostData.host);") === false ||
+ strpos($functionsJs, "$('#host').append(option);") === false) {
+ fwrite(STDERR, "Expected DOM-safe host option rendering in js/functions.js.\n");
+ exit(1);
+}
+
+if (strpos($functionsJs, "$('#host').append('');") !== false) {
+ fwrite(STDERR, "Legacy unsafe host option HTML concatenation still present.\n");
+ exit(1);
+}
+
+echo "issue252_xss_output_test passed\n";