Skip to content

Commit d28d0bb

Browse files
committed
Implements #6822 Disallow backslashes in URL cron
1 parent a603598 commit d28d0bb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

interface/lib/classes/validate_cron.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ function command_format($field_name, $field_value, $validator) {
5353
if($parsed["scheme"] != "http" && $parsed["scheme"] != "https") return $this->get_error($validator['errmsg']);
5454

5555
if(preg_match("'^([a-z0-9][a-z0-9_\-]{0,62}\.)+([A-Za-z0-9\-]{2,63})$'i", $parsed["host"]) == false) return $this->get_error($validator['errmsg']);
56+
57+
if(strpos($field_value, '\\') !== false) {
58+
return $this->get_error($validator['errmsg']);
59+
}
5660
}
5761
if(strpos($field_value, "\n") !== false || strpos($field_value, "\r") !== false || strpos($field_value, chr(0)) !== false) {
5862
return $this->get_error($validator['errmsg']);

server/plugins-available/cron_plugin.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ function _write_crontab() {
254254

255255
$cron_line .= "\t{$this->parent_domain['system_user']}"; //* running as user
256256
if($job['type'] == 'url') {
257+
// Check that command does not contain a backslash
258+
if (strpos($job['command'], '\\') !== false) {
259+
$app->log("Insecure Cron job SKIPPED: " . $job['command'], LOGLEVEL_WARN);
260+
continue;
261+
}
257262
$cron_line .= "\t{$cron_config['wget']} --no-check-certificate --user-agent='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0' -q -t 1 -T 7200 -O " . $log_wget_target . " " . escapeshellarg($job['command']) . " " . $log_target;
258263
} else {
259264
$web_root = '';

0 commit comments

Comments
 (0)