Skip to content

Commit

Permalink
Prevent command injection attacks via the cputime parameter. Fixes
Browse files Browse the repository at this point in the history
issue #39 (#39).
Thanks Marlon (myxxl).
  • Loading branch information
trampgeek committed Nov 20, 2020
1 parent 955fa79 commit 8f43daf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions application/libraries/LanguageTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,25 @@ public function run_in_sandbox($wrappedCmd, $iscompile=true, $stdin=null) {

/*
* Get the value of the job parameter $key, which is taken from the
* value copied into $this from the run request if present of from the
* value copied into $this from the run request if present or from the
* system defaults otherwise.
* If a non-numeric value is provided for a parameter that has a numeric
* default, the default is used instead. This prevents command injection
* as per issue #39 (https://github.com/trampgeek/jobe/issues/39). Thanks
* Marlon (myxl).
* If $iscompile is true and the parameter value is less than that specified
* in $min_params_compile (except if it's 0 meaning no limit), the minimum
* value is used instead.
*/
protected function getParam($key, $iscompile=false) {
$default = $this->default_params[$key];
if (isset($this->params) && array_key_exists($key, $this->params)) {
$param = $this->params[$key];
if (is_numeric($default) && !is_numeric($param)) {
$param = $default; // Prevent command injection attacks.
}
} else {
$param = $this->default_params[$key];
$param = $default;
}
// ** BUG ** The min_params_compile value is being applied even if
// this is not a compile. I'm reluctant to fix, however, as it may
Expand All @@ -347,6 +355,7 @@ protected function getParam($key, $iscompile=false) {
}



// Check if PHP exec environment includes a PATH. If not, set up a
// default, or gcc misbehaves. [Thanks to Binoj D for this bug fix,
// needed on his CentOS system.]
Expand Down

0 comments on commit 8f43daf

Please sign in to comment.