Skip to content

XSS vulnerability when importing a template file

Moderate
netniV published GHSA-xwqc-7jc4-xm73 Dec 20, 2023

Package

cacti

Affected versions

1.2.25

Patched versions

1.2.26

Description

Summary

A reflection XSS vulnerability was discovered. Attackers can exploit this vulnerability to perform actions on behalf of other users.

Details

The vulnerability is found in templates_import.php. When uploading an xml template file, if the XML file does not pass the check, the server will give a JavaScript pop-up prompt, which contains unfiltered xml template file name, resulting in XSS.

$debug_data = import_xml_data($xml_data, $import_as_new, $profile_id, $remove_orphans, $replace_svalues, $import_hashes);
if (!$preview_only) {
	// ...
} elseif ($debug_data !== false && cacti_sizeof($debug_data)) {
	// ...
} else {
	cacti_log(sprintf("ERROR: Import or Preview failed for XML file %s!", $_FILES['import_file']['name']), false, 'IMPORT');
	$message_text = '';
	if (cacti_sizeof($import_messages)) {
		foreach($import_messages as $message) {
			if (isset($messages[$message])) {
				$message_text .= ($message_text != '' ? '<br>':'') . $messages[$message]['message'];
			}
		}
	}
	raise_message_javascript(__('Error in Template', 'package'), __('The Template XML file "%s" validation failed', $_FILES['import_file']['name']), __('See the cacti.log for more information, and review the XML file for proper syntax.  The error details are shown below.<br><br><b>Errors:</b><br>%s', $message_text));

raise_message_javascript() function passed an XML file name, which has not been rigorously verified. The variable $header contains the file name.

function raise_message_javascript($title, $header, $message) {
	?>
	<script type='text/javascript'>
	var mixedReasonTitle = '<?php print $title;?>';
	var mixedOnPage      = '<?php print $header;?>';
	sessionMessage   = {
		message: '<?php print $message;?>',
		level: MESSAGE_LEVEL_MIXED
	};

	$(function() {
		displayMessages();
	});
	</script>
	<?php
	exit;
}

PoC

  1. Login to Cacti
  2. Access to "http://ip/cacti/templates_import.php"
  3. Prepare an empty XML file named ';alert(1);var xx = '.xml
  4. upload this file.
    image

Impact

An attacker exploiting this vulnerability could execute actions on behalf of other users. This ability to impersonate users could lead to unauthorized changes to settings.

Severity

Moderate
5.4
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
Low
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L

CVE ID

CVE-2023-50250

Weaknesses

No CWEs

Credits