-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce max_multipart_body_parts INI
This fixes GHSA-54hq-v5wp-fqgv DOS vulnerabality by limitting number of parsed multipart body parts as currently all parts were always parsed.
- Loading branch information
Showing
7 changed files
with
262 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
sapi/fpm/tests/ghsa-54hq-v5wp-fqgv-max-body-parts-custom.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--TEST-- | ||
FPM: GHSA-54hq-v5wp-fqgv - max_multipart_body_parts ini custom value | ||
--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 | ||
php_admin_value[html_errors] = false | ||
php_admin_value[max_input_vars] = 20 | ||
php_admin_value[max_file_uploads] = 5 | ||
php_admin_value[max_multipart_body_parts] = 10 | ||
php_flag[display_errors] = On | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
var_dump(count(\$_POST)); | ||
EOT; | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
echo $tester | ||
->request(stdin: [ | ||
'parts' => [ | ||
'count' => 30, | ||
] | ||
]) | ||
->getBody(); | ||
$tester->terminate(); | ||
$tester->close(); | ||
|
||
?> | ||
--EXPECT-- | ||
Warning: Unknown: Multipart body parts limit exceeded 10. To increase the limit change max_multipart_body_parts in php.ini. in Unknown on line 0 | ||
int(10) | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
54 changes: 54 additions & 0 deletions
54
sapi/fpm/tests/ghsa-54hq-v5wp-fqgv-max-body-parts-default.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
FPM: GHSA-54hq-v5wp-fqgv - max_multipart_body_parts ini default | ||
--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 | ||
php_admin_value[html_errors] = false | ||
php_admin_value[max_input_vars] = 20 | ||
php_admin_value[max_file_uploads] = 5 | ||
php_flag[display_errors] = On | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
var_dump(count(\$_POST)); | ||
EOT; | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
echo $tester | ||
->request(stdin: [ | ||
'parts' => [ | ||
'count' => 30, | ||
] | ||
]) | ||
->getBody(); | ||
$tester->terminate(); | ||
$tester->close(); | ||
|
||
?> | ||
--EXPECT-- | ||
Warning: Unknown: Input variables exceeded 20. To increase the limit change max_input_vars in php.ini. in Unknown on line 0 | ||
|
||
Warning: Unknown: Multipart body parts limit exceeded 25. To increase the limit change max_multipart_body_parts in php.ini. in Unknown on line 0 | ||
int(20) | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--TEST-- | ||
FPM: GHSA-54hq-v5wp-fqgv - exceeding max_file_uploads | ||
--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 | ||
php_admin_value[html_errors] = false | ||
php_admin_value[max_file_uploads] = 5 | ||
php_flag[display_errors] = On | ||
EOT; | ||
|
||
$code = <<<EOT | ||
<?php | ||
var_dump(count(\$_FILES)); | ||
EOT; | ||
|
||
$tester = new FPM\Tester($cfg, $code); | ||
$tester->start(); | ||
$tester->expectLogStartNotices(); | ||
echo $tester | ||
->request(stdin: [ | ||
'parts' => [ | ||
'count' => 10, | ||
'param' => 'filename' | ||
] | ||
]) | ||
->getBody(); | ||
$tester->terminate(); | ||
$tester->close(); | ||
|
||
?> | ||
--EXPECT-- | ||
Warning: Maximum number of allowable file uploads has been exceeded in Unknown on line 0 | ||
int(5) | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters