summaryrefslogtreecommitdiff
path: root/sapi/fpm/tests
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2019-10-21 13:17:32 -0700
committerStanislav Malyshev <stas@php.net>2019-10-21 13:17:32 -0700
commit6bef57f2e27239ceb88d2dc3a44fbecb7cdfe8e7 (patch)
treefddfc147ee41831c2323ef978531026f79c83a7e /sapi/fpm/tests
parent084d401bebcf67bb4531a6f485f169cc7dcb5737 (diff)
parent59953efc095883cce10fc8410cd186d3df827bbc (diff)
downloadphp-git-6bef57f2e27239ceb88d2dc3a44fbecb7cdfe8e7.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fix bug #78599 (env_path_info underflow can lead to RCE) (CVE-2019-11043) bump versions after release set versions for release
Diffstat (limited to 'sapi/fpm/tests')
-rw-r--r--sapi/fpm/tests/bug78599-path-info-underflow.phpt61
-rw-r--r--sapi/fpm/tests/tester.inc11
2 files changed, 70 insertions, 2 deletions
diff --git a/sapi/fpm/tests/bug78599-path-info-underflow.phpt b/sapi/fpm/tests/bug78599-path-info-underflow.phpt
new file mode 100644
index 0000000000..edd4e0d496
--- /dev/null
+++ b/sapi/fpm/tests/bug78599-path-info-underflow.phpt
@@ -0,0 +1,61 @@
+--TEST--
+FPM: bug78599 - env_path_info underflow - CVE-2019-11043
+--SKIPIF--
+<?php include "skipif.inc"; ?>
+--FILE--
+<?php
+
+require_once "tester.inc";
+
+$cfg = <<<EOT
+[global]
+error_log = {{FILE:LOG}}
+[unconfined]
+listen = {{ADDR}}
+pm = dynamic
+pm.max_children = 5
+pm.start_servers = 1
+pm.min_spare_servers = 1
+pm.max_spare_servers = 3
+EOT;
+
+$code = <<<EOT
+<?php
+echo "Test Start\n";
+var_dump(\$_SERVER["PATH_INFO"]);
+echo "Test End\n";
+EOT;
+
+$tester = new FPM\Tester($cfg, $code);
+$tester->start();
+$tester->expectLogStartNotices();
+$uri = $tester->makeSourceFile();
+$tester
+ ->request(
+ '',
+ [
+ 'SCRIPT_FILENAME' => $uri . "/" . str_repeat('A', 35),
+ 'PATH_INFO' => '',
+ 'HTTP_HUI' => str_repeat('PTEST', 1000),
+ ],
+ $uri
+ )
+ ->expectBody(
+ [
+ 'Test Start',
+ 'string(0) ""',
+ 'Test End'
+ ]
+ );
+$tester->terminate();
+$tester->close();
+
+?>
+Done
+--EXPECT--
+Done
+--CLEAN--
+<?php
+require_once "tester.inc";
+FPM\Tester::clean();
+?>
diff --git a/sapi/fpm/tests/tester.inc b/sapi/fpm/tests/tester.inc
index 0bbf0c5100..b2a387638e 100644
--- a/sapi/fpm/tests/tester.inc
+++ b/sapi/fpm/tests/tester.inc
@@ -509,7 +509,7 @@ class Tester
return new Response(null, true);
}
if (is_null($uri)) {
- $uri = $this->makeFile('src.php', $this->code);
+ $uri = $this->makeSourceFile();
}
$params = array_merge(
@@ -534,7 +534,6 @@ class Tester
],
$headers
);
-
try {
$this->response = new Response(
$this->getClient($address, $connKeepAlive)->request_data($params, false)
@@ -941,6 +940,14 @@ class Tester
}
/**
+ * @return string
+ */
+ public function makeSourceFile()
+ {
+ return $this->makeFile('src.php', $this->code);
+ }
+
+ /**
* @param string|null $msg
*/
private function message($msg)