Skip to content

Commit 9eafbe9

Browse files
committed
Annotate the two remaining exec sinks for Semgrep
Semgrep's diff scan re-reports php.lang.security.exec-use on both lines, because the lines changed — the constructs themselves are pre-existing and are already among master's open findings. Both are now the mitigated versions, so they are annotated with the reason rather than left to fail the check: - isRunning(): the interpolated value is the intval() directly above, guarded > 0, so only digits can reach the shell. - start(): $call comes from start_command(), where every caller-supplied part is escapeshellarg()'d and every unquoted token is a fixed flag name. This is precisely the sink this change exists to make safe, and the regression tests pin it with payloads that fail on the pre-fix code.
1 parent 8cfd7df commit 9eafbe9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/Local.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public function isRunning() {
100100
$pid = intval($this->pid);
101101
if ($pid <= 0)
102102
return False;
103+
// $pid is the intval() above, guarded > 0, so the only bytes that can
104+
// reach the shell here are digits.
105+
// nosemgrep: php.lang.security.exec-use.exec-use
103106
$return_message = shell_exec("ps -" . $pid . " | wc -l");
104107
if (intval($return_message) > 1)
105108
{
@@ -172,6 +175,11 @@ public function start($arguments) {
172175
// file literally named '$this->logfile' instead of the configured one.
173176
system("echo \"\" > " . self::esc($this->logfile));
174177
$call = $call . " 2>&1";
178+
// $call comes from start_command(), where every caller-supplied part is
179+
// escapeshellarg()'d and every unquoted token is a fixed flag name. This is
180+
// the sink the whole change exists to make safe; tests/LocalTest.php pins
181+
// that with payloads that fail on the pre-fix code.
182+
// nosemgrep: php.lang.security.exec-use.exec-use
175183
$return_message = shell_exec($call);
176184
$data = json_decode($return_message,true);
177185
if ($data["state"] != "connected") {

0 commit comments

Comments
 (0)