Skip to content

Commit

Permalink
fix!: fix bug where single quotes are escaped in CLI process (adding:…
Browse files Browse the repository at this point in the history
… %27)

changed to more secure PHP escapeshellarg
  • Loading branch information
Paco committed May 13, 2024
1 parent 559e76a commit 238b847
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions core/common/class.exec_.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,6 @@ public static function request_cli(object $options) : object {
foreach ($params as $key => $value) {
$safe_params->{$key} = safe_xss($value);
}
$safe_params_string = json_encode($safe_params);
// replace single quotes by the URL encoding value %27
$safe_params_string = str_replace("'", '%27', $safe_params_string);
// restore object safe_params after escape it
$safe_params = json_decode($safe_params_string);

// server_vars
// sh_data mandatory vars
Expand All @@ -346,7 +341,7 @@ public static function request_cli(object $options) : object {
$process_runner = DEDALO_CORE_PATH . '/base/process_runner.php';

// command composition
$cmd = PHP_BIN_PATH . " $process_runner '$server_vars' ";
$cmd = PHP_BIN_PATH . " $process_runner " . escapeshellarg($server_vars);
$command = "nohup nice -n 19 $cmd >$file_path 2>&1 & echo $!";

// debug
Expand Down

0 comments on commit 238b847

Please sign in to comment.