[php-src] PR #22223: Reject negative request_parse_body() limit options

From: Date: Thu, 04 Jun 2026 04:42:52 +0000
Subject: [php-src] PR #22223: Reject negative request_parse_body() limit options
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36292@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22223 Author: OracleNep request_parse_body() currently accepts negative values for limit-related options. This can weaken or bypass request body limits. In particular, for application/x-www-form-urlencoded bodies, max_input_vars is read into an unsigned uint64_t, so passing max_input_vars => -1 effectively turns the limit into a very large value. post_max_size => -1 also disables the size check, because the check only runs when the configured value is greater than zero. This patch rejects negative values for: ```text max_file_uploads max_input_vars post_max_size upload_max_filesize ``` max_multipart_body_parts is left unchanged because negative values currently have a special meaning there: derive the multipart body part limit from max_input_vars + max_file_uploads. This is a hardening / validation fix, not a security report. The options are supplied by application code, but accepting negative values makes it easy to accidentally disable request body limits. ### Local verification Using php-src master be41c36b68f, tested with the built-in web server: ```text request_parse_body(['max_input_vars' => -1]) ``` accepted all urlencoded fields, while: ```text request_parse_body(['max_input_vars' => 1]) ``` triggered the expected max-input-vars warning path. Also verified: ```text request_parse_body(['post_max_size' => -1]) ``` accepted a body that was rejected when post_max_size => 1. ### Tests ```bash sapi/cli/php run-tests.php ext/standard/tests/http/request_parse_body/options_negative_values.phpt sapi/cli/php run-tests.php ext/standard/tests/http/request_parse_body ```

« previous php.git-pulls (#36292) next »