From c2f03e8caa6848f65633af2bb528cc35d65f2818 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Wed, 8 Apr 2026 22:42:25 -0700 Subject: [PATCH 1/5] fix(security): defense-in-depth hardening for plugin_mactrack Automated fixes: - XSS: escape request variables in HTML output - SQLi: convert string-concat queries to prepared statements - Deserialization: add allowed_classes=>false - Temp files: replace rand() with tempnam() Signed-off-by: Thomas Vincent --- Net/DNS2/Cache.php | 2 +- Net/DNS2/Cache/File.php | 4 ++-- Net/DNS2/Cache/Shm.php | 4 ++-- lib/mactrack_functions.php | 2 +- mactrack_device_types.php | 2 +- mactrack_devices.php | 2 +- mactrack_macauth.php | 4 ++-- mactrack_macwatch.php | 4 ++-- mactrack_snmp.php | 4 ++-- mactrack_vendormacs.php | 2 +- mactrack_view_arp.php | 2 +- mactrack_view_devices.php | 4 ++-- mactrack_view_interfaces.php | 2 +- mactrack_view_ips.php | 2 +- mactrack_view_macs.php | 4 ++-- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Net/DNS2/Cache.php b/Net/DNS2/Cache.php index dadf1cf..7429f14 100644 --- a/Net/DNS2/Cache.php +++ b/Net/DNS2/Cache.php @@ -67,7 +67,7 @@ public function get($key) { if ($this->cache_serializer == 'json') { return json_decode($this->cache_data[$key]['object']); } else { - return unserialize($this->cache_data[$key]['object']); + return unserialize($this->cache_data[$key]['object'], array('allowed_classes' => false)); } } else { return false; diff --git a/Net/DNS2/Cache/File.php b/Net/DNS2/Cache/File.php index 5122451..7e58eff 100644 --- a/Net/DNS2/Cache/File.php +++ b/Net/DNS2/Cache/File.php @@ -67,7 +67,7 @@ public function open($cache_file, $size, $serializer) { if ($this->cache_serializer == 'json') { $decoded = json_decode($data, true); } else { - $decoded = unserialize($data); + $decoded = unserialize($data, array('allowed_classes' => false)); } if (is_array($decoded) == true) { @@ -145,7 +145,7 @@ public function __destruct() { if ($this->cache_serializer == 'json') { $decoded = json_decode($data, true); } else { - $decoded = unserialize($data); + $decoded = unserialize($data, array('allowed_classes' => false)); } if (is_array($decoded) == true) { diff --git a/Net/DNS2/Cache/Shm.php b/Net/DNS2/Cache/Shm.php index 690719c..b0a61dc 100644 --- a/Net/DNS2/Cache/Shm.php +++ b/Net/DNS2/Cache/Shm.php @@ -104,7 +104,7 @@ public function open($cache_file, $size, $serializer) { if ($this->cache_serializer == 'json') { $decoded = json_decode($data, true); } else { - $decoded = unserialize($data); + $decoded = unserialize($data, array('allowed_classes' => false)); } if (is_array($decoded) == true) { @@ -195,7 +195,7 @@ public function __destruct() { if ($this->cache_serializer == 'json') { $decoded = json_decode($data, true); } else { - $decoded = unserialize($data); + $decoded = unserialize($data, array('allowed_classes' => false)); } if (is_array($decoded) == true) { diff --git a/lib/mactrack_functions.php b/lib/mactrack_functions.php index 9c47f6d..893c16c 100644 --- a/lib/mactrack_functions.php +++ b/lib/mactrack_functions.php @@ -3582,7 +3582,7 @@ function mactrack_site_filter($page = 'mactrack_sites.php') { - '> + '> diff --git a/mactrack_device_types.php b/mactrack_device_types.php index 0ee23f6..abc913d 100644 --- a/mactrack_device_types.php +++ b/mactrack_device_types.php @@ -1053,7 +1053,7 @@ function mactrack_device_type_filter() { - '> + '> diff --git a/mactrack_devices.php b/mactrack_devices.php index 1435db5..5c68960 100644 --- a/mactrack_devices.php +++ b/mactrack_devices.php @@ -1160,7 +1160,7 @@ function mactrack_device_filter() { - '> + '> diff --git a/mactrack_macauth.php b/mactrack_macauth.php index b559f07..5f53a39 100644 --- a/mactrack_macauth.php +++ b/mactrack_macauth.php @@ -384,7 +384,7 @@ function mactrack_maca_filter() { - '> + '> @@ -413,7 +413,7 @@ function mactrack_maca_filter() { - '> + '>