Skip to content

Commit b3fdce8

Browse files
security: support array arguments in exec_background and __rrd_execute (1.2.x backport)
- Accept array $args in exec_background(), auto-escape via cacti_escapeshellarg() - Accept array $command_line in __rrd_execute(), auto-escape via cacti_escapeshellarg() - Backward compatible: string arguments still work unchanged Addresses GHSA-8522-5p3m-754c (High) - Authenticated RCE via Host Variable Injection Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent cea6212 commit b3fdce8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/poller.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ function exec_poll_php($command, $using_proc_function, $pipes, $proc_fd) {
132132
function exec_background($filename, $args = '', $redirect_args = '') {
133133
global $config, $debug;
134134

135+
if (is_array($args)) {
136+
$args = implode(' ', array_map('cacti_escapeshellarg', $args));
137+
}
138+
139+
if (is_array($redirect_args)) {
140+
$redirect_args = implode(' ', $redirect_args);
141+
}
142+
135143
cacti_log("DEBUG: About to Spawn a Remote Process [CMD: $filename, ARGS: $args]", true, 'POLLER', ($debug ? POLLER_VERBOSITY_NONE:POLLER_VERBOSITY_DEBUG));
136144

137145
if (file_exists($filename)) {

lib/rrd.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ function rrdtool_execute() {
255255
function __rrd_execute($command_line, $log_to_stdout, $output_flag, $rrdtool_pipe = false, $logopt = 'WEBLOG') {
256256
global $config;
257257

258+
if (is_array($command_line)) {
259+
$command_line = implode(' ', array_map('cacti_escapeshellarg', $command_line));
260+
}
261+
258262
static $last_command;
259263

260264
if (!is_numeric($output_flag)) {

0 commit comments

Comments
 (0)