You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: log injection guard and XML parse validation in import handler
- htmlspecialchars() on PARTITION_NAME in error log to prevent log
line forgery if name contains control characters or newlines
- simplexml_load_string() tertiary check after MIME sniff; a crafted
file can pass mime_content_type() while containing malformed XML;
parse failure is the authoritative rejection gate
@@ -250,6 +272,19 @@ function syslog_get_import_xml_payload($redirect_url) {
250
272
exit;
251
273
}
252
274
275
+
/* Tertiary: parse the content to confirm it is well-formed XML.
276
+
mime_content_type() is heuristic and can be spoofed by crafted files;
277
+
a successful parse is the authoritative check. */
278
+
libxml_use_internal_errors(true);
279
+
$parsed = simplexml_load_string($xml_data);
280
+
libxml_clear_errors();
281
+
libxml_use_internal_errors(false);
282
+
if ($parsed === false) {
283
+
cacti_log('SYSLOG ERROR: Uploaded import file is not well-formed XML', false, 'SYSTEM');
284
+
header('Location: ' . $redirect_url);
285
+
exit;
286
+
}
287
+
253
288
return$xml_data;
254
289
}
255
290
@@ -449,7 +484,7 @@ function syslog_partition_remove($table) {
449
484
format before DDL interpolation — MySQL does not support parameter
450
485
binding for DDL statements. */
451
486
if (!preg_match('/^d\d{8}$/', $oldest['PARTITION_NAME'])) {
452
-
cacti_log("SYSLOG ERROR: Unexpected partition name format '" . $oldest['PARTITION_NAME'] . "' for table '$table', skipping, cannot prune past this entry", false, 'SYSTEM');
487
+
cacti_log("SYSLOG ERROR: Unexpected partition name format '" . htmlspecialchars($oldest['PARTITION_NAME'], ENT_QUOTES, 'UTF-8') . "' for table '$table', skipping, cannot prune past this entry", false, 'SYSTEM');
453
488
/* Stop immediately: partitions are ordered by age, so an invalid
454
489
name means we cannot safely drop any further entries. Breaking
455
490
here also ensures the loop terminates even if all remaining
@@ -969,22 +1004,30 @@ function syslog_manage_items($from_table, $to_table) {
0 commit comments