exec calls should use escapeshellarg
-
exec
calls should use the escapeshellarg function to escape arguments, so that paths and names won’t get interpreted by the shell and lead to confusion or even security issues (shell injection).Here is an example of the patch for jpg optimization code (other
exec
calls need to be fixed in a similar manner):--- a/wordpress/wp-content/plugins/ewww-image-optimizer/ewww-image-optimizer.php +++ b/wordpress/wp-content/plugins/ewww-image-optimizer/ewww-image-optimizer.php @@ -1747,9 +1747,9 @@ function ewww_image_optimizer($file, $gallery_type, $converted, $resize) { $copy_opt = 'all'; } // run jpegtran - non-progressive - exec("$nice " . $tools['JPEGTRAN'] . " -copy $copy_opt -optimize -outfile $tempfile $file"); + exec("$nice " . $tools['JPEGTRAN'] . " -copy $copy_opt -optimize -outfile " . escapeshellarg($tempfile) . " " . escapeshellarg($file)); // run jpegtran - progressive - exec("$nice " . $tools['JPEGTRAN'] . " -copy $copy_opt -optimize -progressive -outfile $progfile $file"); + exec("$nice " . $tools['JPEGTRAN'] . " -copy $copy_opt -optimize -progressive -outfile " . escapeshellarg($progfile) . " " . escapeshellarg($file)); // check the filesize of the non-progressive JPG $non_size = filesize($tempfile); // check the filesize of the progressive JPG
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘exec calls should use escapeshellarg’ is closed to new replies.