CVE-2022-46169: Incorrect Authorization (CWE-863)
value: Cacti is an open source platform which provides a robust and extensible operational monitoring and fault management framework for users. In affected versions a command injection vulnerability allows an unauthenticated user to execute arbitrary code on a server running Cacti, if a specific data source was selected for any monitored device. The vulnerability resides in the `remote_agent.php` file. This file can be accessed without authentication. This function retrieves the IP address of the client via `get_client_addr` and resolves this IP address to the corresponding hostname via `gethostbyaddr`. After this, it is verified that an entry within the `poller` table exists, where the hostname corresponds to the resolved hostname. If such an entry was found, the function returns `true` and the client is authorized. This authorization can be bypassed due to the implementation of the `get_client_addr` function. The function is defined in the file `lib/functions.php` and checks serval `$_SERVER` variables to determine the IP address of the client. The variables beginning with `HTTP_` can be arbitrarily set by an attacker. Since there is a default entry in the `poller` table with the hostname of the server running Cacti, an attacker can bypass the authentication e.g. by providing the header `Forwarded-For: <TARGETIP>`. This way the function `get_client_addr` returns the IP address of the server running Cacti. The following call to `gethostbyaddr` will resolve this IP address to the hostname of the server, which will pass the `poller` hostname check because of the default entry. After the authorization of the `remote_agent.php` file is bypassed, an attacker can trigger different actions. One of these actions is called `polldata`. The called function `poll_for_data` retrieves a few request parameters and loads the corresponding `poller_item` entries from the database. If the `action` of a `poller_item` equals `POLLER_ACTION_SCRIPT_PHP`, the function `proc_open` is used to execute a PHP script. The attacker-controlled parameter `$poller_id` is retrieved via the function `get_nfilter_request_var`, which allows arbitrary strings. This variable is later inserted into the string passed to `proc_open`, which leads to a command injection vulnerability. By e.g. providing the `poller_id=;id` the `id` command is executed. In order to reach the vulnerable call, the attacker must provide a `host_id` and `local_data_id`, where the `action` of the corresponding `poller_item` is set to `POLLER_ACTION_SCRIPT_PHP`. Both of these ids (`host_id` and `local_data_id`) can easily be bruteforced. The only requirement is that a `poller_item` with an `POLLER_ACTION_SCRIPT_PHP` action exists. This is very likely on a productive instance because this action is added by some predefined templates like `Device - Uptime` or `Device - Polling Time`.

This command injection vulnerability allows an unauthenticated user to execute arbitrary commands if a `poller_item` with the `action` type `POLLER_ACTION_SCRIPT_PHP` (`2`) is configured. The authorization bypass should be prevented by not allowing an attacker to make `get_client_addr` (file `lib/functions.php`) return an arbitrary IP address. This could be done by not honoring the `HTTP_...` `$_SERVER` variables. If these should be kept for compatibility reasons it should at least be prevented to fake the IP address of the server running Cacti. This vulnerability has been addressed in both the 1.2.x and 1.3.x release branches with `1.2.23` being the first release containing the patch.
CWE description: The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
CVSS v3 base score: 9.8
Published: 2022-12-05T21:15Z
Repository: https://github.com/Cacti/cacti
Language: PHP
Files changed: CHANGELOG, auth_login.php, include/config.php.dist, include/global.php, include/global_arrays.php, lib/auth.php, lib/functions.php, remote_agent.php
Commit date: 2022-12-05 08:41:01 +0000
Commit message: Merge pull request from GHSA-6p93-p743-35gf

* Resolving  CVE-2022-46169

* Provide a restrictive option

* QA: Further restrict allowed headers to those defined in config only

Co-authored-by: TheWitness <thewitness@cacti.net>
Diff: diff --git a/CHANGELOG b/CHANGELOG
index a807509ebd..ff4d208c92 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -44,10 +44,11 @@ Cacti CHANGELOG
 -feature#5025: Add Least Squares Special Data Types to Cacti
 -feature#5027: Add Service Check Filter and Column and Device Thread Column
 
 1.2.23
 -security#4920: Add .htaccess file to scripts folder
+-security#XXXX: CVE-2022-46169 Unauthenticated Command Injection in Remote Agent
 -issue#4418: When using Single Signon Frameworks like SiteMinder Cacti does not properly detect ticket revocation in callbacks
 -issue#4682: New templates are not installed during the update
 -issue#4838: CLI Based upgrade generates warnings in PHP 8.1
 -issue#4888: Cacti audit_database.php script fails on MySQL 8.0.29 and likely will on newer versions
 -issue#4889: Increase host query performance by removing check for NULL after 1.2.22
diff --git a/auth_login.php b/auth_login.php
index 41e9732755..2ee70dceab 100644
--- a/auth_login.php
+++ b/auth_login.php
@@ -159,11 +159,11 @@ if (get_nfilter_request_var('action') == 'login' || $auth_method == 2) {
 			cacti_log("LOGIN: User '" . $user['username'] . "' authenticated", false, 'AUTH');
 		} else {
 			cacti_log("LOGIN: Guest User '" . $user['username'] . "' in use", false, 'AUTH');
 		}
 
-		$client_addr = get_client_addr('');
+		$client_addr = get_client_addr();
 
 		db_execute_prepared(
 			'INSERT IGNORE INTO user_log
 			(username, user_id, result, ip, time)
 			VALUES (?, ?, 1, ?, NOW())',
@@ -267,14 +267,14 @@ if (get_nfilter_request_var('action') == 'login' || $auth_method == 2) {
 		/* BAD username/password builtin and LDAP */
 		db_execute_prepared(
 			'INSERT IGNORE INTO user_log
 			(username, user_id, result, ip, time)
 			VALUES (?, ?, 0, ?, NOW())',
-			array($username, !empty($id) ? $id : 0, get_client_addr(''))
+			array($username, !empty($id) ? $id : 0, get_client_addr())
 		);
 
-		cacti_log('LOGIN FAILED: ' . $realm_name . " Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.", false, 'AUTH');
+		cacti_log('LOGIN FAILED: ' . $realm_name . " Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.", false, 'AUTH');
 	}
 }
 
 if (api_plugin_hook_function('custom_login', OPER_MODE_NATIVE) == OPER_MODE_RESKIN) {
 	return;
diff --git a/include/config.php.dist b/include/config.php.dist
index 40f3f98a61..686b035524 100644
--- a/include/config.php.dist
+++ b/include/config.php.dist
@@ -162,5 +162,31 @@ $disable_log_rotation = false;
 /*
  * Debug the flow of calls to the db_xxx functions that
  * are defined in lib/database.php
  */
 # define('DEBUG_SQL_FLOW', true);
+
+/*
+ * Allow the use of Proxy IPs when searching for client
+ * IP to be used
+ *
+ * This can be set to one of the following:
+ *   - false: to use only REMOTE_ADDR
+ *   - true: to use all allowed headers (not advised)
+ *   - array of one or more the following:
+ *		'X-Forwarded-For',
+ *		'X-Client-IP',
+ *		'X-Real-IP',
+ *		'X-ProxyUser-Ip',
+ *		'CF-Connecting-IP',
+ *		'True-Client-IP',
+ *		'HTTP_X_FORWARDED',
+ *		'HTTP_X_FORWARDED_FOR',
+ *		'HTTP_X_CLUSTER_CLIENT_IP',
+ *		'HTTP_FORWARDED_FOR',
+ *		'HTTP_FORWARDED',
+ *		'HTTP_CLIENT_IP',
+ *
+ * NOTE: The following will always be checked:
+ *		'REMOTE_ADDR',
+ */
+$proxy_headers = null;
diff --git a/include/global.php b/include/global.php
index 90746e4caa..faa75f0d49 100644
--- a/include/global.php
+++ b/include/global.php
@@ -143,10 +143,13 @@ if (file_exists(dirname(__FILE__) . '/config.php')) {
 if (isset($config['cacti_version'])) {
 	die('Invalid include/config.php file detected.' . PHP_EOL);
 	exit;
 }
 
+/* Should we allow proxy ip headers? */
+$config['proxy_headers'] = $proxy_headers ?? null;
+
 /* Set the poller_id */
 if (isset($poller_id)) {
 	$config['poller_id'] = $poller_id;
 } else {
 	$config['poller_id'] = 1;
diff --git a/include/global_arrays.php b/include/global_arrays.php
index aa52d61f75..80383f22d3 100644
--- a/include/global_arrays.php
+++ b/include/global_arrays.php
@@ -2929,6 +2929,22 @@ if ($config['cacti_server_os'] == 'unix') {
 	$dejavu_paths = array(
 		'C:/Windows/Fonts/' //Windows
 	);
 }
 
+$allowed_proxy_headers =	array(
+	'X-Forwarded-For',
+	'X-Client-IP',
+	'X-Real-IP',
+	'X-ProxyUser-Ip',
+	'CF-Connecting-IP',
+	'True-Client-IP',
+	'HTTP_X_FORWARDED',
+	'HTTP_X_FORWARDED_FOR',
+	'HTTP_X_CLUSTER_CLIENT_IP',
+	'HTTP_FORWARDED_FOR',
+	'HTTP_FORWARDED',
+	'HTTP_CLIENT_IP',
+	'REMOTE_ADDR',
+);
+
 api_plugin_hook('config_arrays');
diff --git a/lib/auth.php b/lib/auth.php
index a66573884d..54e87c3872 100644
--- a/lib/auth.php
+++ b/lib/auth.php
@@ -81,19 +81,19 @@ function set_auth_cookie($user) {
 	global $config;
 
 	if (db_table_exists('user_auth_cache')) {
 		clear_auth_cookie();
 
-		$nssecret = md5($_SERVER['REQUEST_TIME'] .  mt_rand(10000,10000000)) . md5(get_client_addr(''));
+		$nssecret = md5($_SERVER['REQUEST_TIME'] .  mt_rand(10000,10000000)) . md5(get_client_addr());
 
 		$secret = hash('sha512', $nssecret, false);
 
 		db_execute_prepared('REPLACE INTO user_auth_cache
 			(user_id, hostname, last_update, token)
 			VALUES
 			(?, ?, NOW(), ?);',
-			array($user['id'], get_client_addr(''), $secret));
+			array($user['id'], get_client_addr(), $secret));
 
 		cacti_cookie_session_set($user['id'], $user['realm'], $nssecret);
 	}
 }
 
@@ -159,11 +159,11 @@ function check_auth_cookie() {
 
 					db_execute_prepared('INSERT IGNORE INTO user_log
 						(username, user_id, result, ip, time)
 						VALUES
 						(?, ?, 2, ?, NOW())',
-						array($user_info['username'], $user_info['id'], get_client_addr(''))
+						array($user_info['username'], $user_info['id'], get_client_addr())
 					);
 
 					return $user_info['id'];
 				}
 			}
@@ -3428,11 +3428,11 @@ function auth_process_lockout($username, $realm) {
 				AND realm = ?",
 				array($username, $realm));
 
 			if (cacti_sizeof($user)) {
 				if ($user['enabled'] == '') {
-					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.  User account Disabled.", false, 'AUTH');
+					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.  User account Disabled.", false, 'AUTH');
 
 					$error     = true;
 					$error_msg = __('Access Denied!  Login Disabled.');
 				}
 
@@ -3462,26 +3462,26 @@ function auth_process_lockout($username, $realm) {
 
 				// Log the invalid password attempt
 				db_execute_prepared('INSERT IGNORE INTO user_log
 					(username, user_id, result, ip, time)
 					VALUES (?, ?, 0, ?, NOW())',
-					array($username, isset($user['id']) ? $user['id']:0, get_client_addr('')));
+					array($username, isset($user['id']) ? $user['id']:0, get_client_addr()));
 
 				if ($user['locked'] == 'on') {
-					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.  Account is locked out.", false, 'AUTH');
+					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.  Account is locked out.", false, 'AUTH');
 
 					$error     = true;
 					$error_msg = __('Your account has been locked.  Please contact your Administrator.');
 				} else {
-					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.", false, 'AUTH');
+					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.", false, 'AUTH');
 
 					/* error */
 					$error     = true;
 					$error_msg = __('Access Denied!  Login Failed.');
 				}
 			} elseif ($user['locked'] == 'on') {
-				cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.", false, 'AUTH');
+				cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.", false, 'AUTH');
 
 				$error     = true;
 				$error_msg = __('Access Denied!  Login Failed.');
 			}
 		}
diff --git a/lib/functions.php b/lib/functions.php
index bb678b21e4..98f87b8921 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -7077,41 +7077,54 @@ function get_debug_prefix() {
 	$dateTime = $dateTime->format('Y-m-d H:i:s.u');
 
 	return sprintf('<[ %s | %7d ]> -- ', $dateTime, getmypid());
 }
 
-function get_client_addr($client_addr = false, $restrictive = false) {
-	if (!$restrictive) {
-		$http_addr_headers = array(
-			'X-Forwarded-For',
-			'X-Client-IP',
-			'X-Real-IP',
-			'X-ProxyUser-Ip',
-			'CF-Connecting-IP',
-			'True-Client-IP',
-			'HTTP_X_FORWARDED',
-			'HTTP_X_FORWARDED_FOR',
-			'HTTP_X_CLUSTER_CLIENT_IP',
-			'HTTP_FORWARDED_FOR',
-			'HTTP_FORWARDED',
-			'HTTP_CLIENT_IP',
-			'REMOTE_ADDR',
-		);
-	} else {
-		$http_addr_headers = array(
-			'X-Forwarded-For',
-			'X-Client-IP',
-			'X-Real-IP',
-			'X-ProxyUser-Ip',
-			'CF-Connecting-IP',
-			'True-Client-IP',
-			'REMOTE_ADDR',
-		);
+function get_client_addr() {
+	global $config, $allowed_proxy_headers;
+
+	$proxy_headers = $config['proxy_headers'] ?? null;
+	if ($proxy_headers === null) {
+		$last_time = read_config_option('proxy_alert');
+		if (empty($last_time)) {
+			$last_time = date('Y-m-d');
+		}
+
+		$last_date = new DateTime($last_time);
+		$this_date = new Datetime();
+
+		$this_diff = $this_date->diff($last_date);
+		$this_days = $this_diff->format('%a');
+
+		if ($this_days) {
+			cacti_log('WARNING: Configuration option "proxy_headers" will be automatically false in future releases.  Please set if you require proxy IPs to be used', false, 'AUTH');
+			set_config_option('proxy_alert', date('Y-m-d'));
+		}
+
+		$proxy_headers = true;
+	}
+
+	/* If proxy_headers is true, allow all known headers -- NOT advised
+	 * If proxy_headers is false, allow only REMOTE_ADDR
+	 * IF proxy_headers is an array, filter by known headers
+	 */
+	if ($proxy_headers === true) {
+		$proxy_headers = $allowed_proxy_headers;
+	} elseif (is_array($proxy_headers)) {
+		$proxy_headers = array_intersect($proxy_headers, $allowed_proxy_headers);
+	}
+
+	if (!is_array($proxy_headers)) {
+		$proxy_headers = [];
+	}
+
+	if (!in_array('REMOTE_ADDR', $proxy_headers)) {
+		$proxy_headers[] = 'REMOTE_ADDR';
 	}
 
 	$client_addr = false;
-	foreach ($http_addr_headers as $header) {
+	foreach ($proxy_headers as $header) {
 		if (!empty($_SERVER[$header])) {
 			$header_ips = explode(',', $_SERVER[$header]);
 			foreach ($header_ips as $header_ip) {
 				if (!empty($header_ip)) {
 					if (!filter_var($header_ip, FILTER_VALIDATE_IP)) {
diff --git a/remote_agent.php b/remote_agent.php
index a894c59dcd..963ade9ca1 100644
--- a/remote_agent.php
+++ b/remote_agent.php
@@ -296,11 +296,11 @@ function ping_device() {
 function poll_for_data() {
 	global $config;
 
 	$local_data_ids = get_nfilter_request_var('local_data_ids');
 	$host_id        = get_filter_request_var('host_id');
-	$poller_id      = get_nfilter_request_var('poller_id');
+	$poller_id      = get_filter_request_var('poller_id');
 	$return         = array();
 
 	$i = 0;
 
 	if (cacti_sizeof($local_data_ids)) {
@@ -380,11 +380,11 @@ function poll_for_data() {
 							1 => array('pipe', 'w'), // stdout is a pipe that the child will write to
 							2 => array('pipe', 'w')  // stderr is a pipe to write to
 						);
 
 						if (function_exists('proc_open')) {
-							$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime ' . $poller_id, $cactides, $pipes);
+							$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime ' . cacti_escapeshellarg($poller_id), $cactides, $pipes);
 							$output = fgets($pipes[1], 1024);
 							$using_proc_function = true;
 						} else {
 							$using_proc_function = false;
 						}
@@ -441,12 +441,12 @@ function run_remote_data_query() {
 }
 
 function run_remote_discovery() {
 	global $config;
 
-	$poller_id = $config['poller_id'];
-	$network   = get_filter_request_var('network');
+	$poller_id = cacti_escapeshellarg($config['poller_id']);
+	$network   = cacti_escapeshellarg(get_filter_request_var('network'));
 	$php       = cacti_escapeshellcmd(read_config_option('path_php_binary'));
 	$path      = cacti_escapeshellarg(read_config_option('path_webroot') . '/poller_automation.php');
 
 	$options   = ' --poller=' . $poller_id . ' --network=' . $network . ' --force';
 	if (isset_request_var('debug')) {

Vulnerable code: 		$client_addr = get_client_addr('');
			array($username, !empty($id) ? $id : 0, get_client_addr(''))
		cacti_log('LOGIN FAILED: ' . $realm_name . " Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.", false, 'AUTH');
		$nssecret = md5($_SERVER['REQUEST_TIME'] .  mt_rand(10000,10000000)) . md5(get_client_addr(''));
			array($user['id'], get_client_addr(''), $secret));
						array($user_info['username'], $user_info['id'], get_client_addr(''))
					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.  User account Disabled.", false, 'AUTH');
					array($username, isset($user['id']) ? $user['id']:0, get_client_addr('')));
					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.  Account is locked out.", false, 'AUTH');
					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.", false, 'AUTH');
				cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr('') . "'.", false, 'AUTH');
function get_client_addr($client_addr = false, $restrictive = false) {
	if (!$restrictive) {
		$http_addr_headers = array(
			'X-Forwarded-For',
			'X-Client-IP',
			'X-Real-IP',
			'X-ProxyUser-Ip',
			'CF-Connecting-IP',
			'True-Client-IP',
			'HTTP_X_FORWARDED',
			'HTTP_X_FORWARDED_FOR',
			'HTTP_X_CLUSTER_CLIENT_IP',
			'HTTP_FORWARDED_FOR',
			'HTTP_FORWARDED',
			'HTTP_CLIENT_IP',
			'REMOTE_ADDR',
		);
	} else {
		$http_addr_headers = array(
			'X-Forwarded-For',
			'X-Client-IP',
			'X-Real-IP',
			'X-ProxyUser-Ip',
			'CF-Connecting-IP',
			'True-Client-IP',
			'REMOTE_ADDR',
		);
	foreach ($http_addr_headers as $header) {
	$poller_id      = get_nfilter_request_var('poller_id');
							$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime ' . $poller_id, $cactides, $pipes);
	$poller_id = $config['poller_id'];
	$network   = get_filter_request_var('network');
Fixed code: -security#XXXX: CVE-2022-46169 Unauthenticated Command Injection in Remote Agent
		$client_addr = get_client_addr();
			array($username, !empty($id) ? $id : 0, get_client_addr())
		cacti_log('LOGIN FAILED: ' . $realm_name . " Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.", false, 'AUTH');

/*
 * Allow the use of Proxy IPs when searching for client
 * IP to be used
 *
 * This can be set to one of the following:
 *   - false: to use only REMOTE_ADDR
 *   - true: to use all allowed headers (not advised)
 *   - array of one or more the following:
 *		'X-Forwarded-For',
 *		'X-Client-IP',
 *		'X-Real-IP',
 *		'X-ProxyUser-Ip',
 *		'CF-Connecting-IP',
 *		'True-Client-IP',
 *		'HTTP_X_FORWARDED',
 *		'HTTP_X_FORWARDED_FOR',
 *		'HTTP_X_CLUSTER_CLIENT_IP',
 *		'HTTP_FORWARDED_FOR',
 *		'HTTP_FORWARDED',
 *		'HTTP_CLIENT_IP',
 *
 * NOTE: The following will always be checked:
 *		'REMOTE_ADDR',
 */
$proxy_headers = null;
/* Should we allow proxy ip headers? */
$config['proxy_headers'] = $proxy_headers ?? null;

$allowed_proxy_headers =	array(
	'X-Forwarded-For',
	'X-Client-IP',
	'X-Real-IP',
	'X-ProxyUser-Ip',
	'CF-Connecting-IP',
	'True-Client-IP',
	'HTTP_X_FORWARDED',
	'HTTP_X_FORWARDED_FOR',
	'HTTP_X_CLUSTER_CLIENT_IP',
	'HTTP_FORWARDED_FOR',
	'HTTP_FORWARDED',
	'HTTP_CLIENT_IP',
	'REMOTE_ADDR',
);

		$nssecret = md5($_SERVER['REQUEST_TIME'] .  mt_rand(10000,10000000)) . md5(get_client_addr());
			array($user['id'], get_client_addr(), $secret));
						array($user_info['username'], $user_info['id'], get_client_addr())
					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.  User account Disabled.", false, 'AUTH');
					array($username, isset($user['id']) ? $user['id']:0, get_client_addr()));
					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.  Account is locked out.", false, 'AUTH');
					cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.", false, 'AUTH');
				cacti_log("LOGIN FAILED: Local Login Failed for user '" . $username . "' from IP Address '" . get_client_addr() . "'.", false, 'AUTH');
function get_client_addr() {
	global $config, $allowed_proxy_headers;

	$proxy_headers = $config['proxy_headers'] ?? null;
	if ($proxy_headers === null) {
		$last_time = read_config_option('proxy_alert');
		if (empty($last_time)) {
			$last_time = date('Y-m-d');
		}

		$last_date = new DateTime($last_time);
		$this_date = new Datetime();

		$this_diff = $this_date->diff($last_date);
		$this_days = $this_diff->format('%a');

		if ($this_days) {
			cacti_log('WARNING: Configuration option "proxy_headers" will be automatically false in future releases.  Please set if you require proxy IPs to be used', false, 'AUTH');
			set_config_option('proxy_alert', date('Y-m-d'));
		}

		$proxy_headers = true;
	}

	/* If proxy_headers is true, allow all known headers -- NOT advised
	 * If proxy_headers is false, allow only REMOTE_ADDR
	 * IF proxy_headers is an array, filter by known headers
	 */
	if ($proxy_headers === true) {
		$proxy_headers = $allowed_proxy_headers;
	} elseif (is_array($proxy_headers)) {
		$proxy_headers = array_intersect($proxy_headers, $allowed_proxy_headers);
	}

	if (!is_array($proxy_headers)) {
		$proxy_headers = [];
	}

	if (!in_array('REMOTE_ADDR', $proxy_headers)) {
		$proxy_headers[] = 'REMOTE_ADDR';
	foreach ($proxy_headers as $header) {
	$poller_id      = get_filter_request_var('poller_id');
							$cactiphp = proc_open(read_config_option('path_php_binary') . ' -q ' . $config['base_path'] . '/script_server.php realtime ' . cacti_escapeshellarg($poller_id), $cactides, $pipes);
	$poller_id = cacti_escapeshellarg($config['poller_id']);
	$network   = cacti_escapeshellarg(get_filter_request_var('network'));