PHP sometimes truncating post requests - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, April 27, 2023

PHP sometimes truncating post requests

We inherited an old PHP server running: Apache 2.4.6 OpenSSL 1.0.2k-fips PHP 5.4.16 mod_perl 2.0.11 Perl v5.15.3

It is also using CodeIgniter 3.0.6.

The PHP code creates an html form with 0-5000 input tags, and submits that form via POST to an internal endpoint also handled by PHP. These 0-5000 input tags are stored in an array called types[].

For example: <input name='types[]' value='myType'/> where myType is some unique string.

In the function that handles this request, we extract the list of types using $types=$this->input->post('types') which returns the list of types submitted by the form.

For some reason, this list is occasionally truncated when a large number of inputs exists. Usually greater than 3000. max_input_vars is set to 100000, so its not that. max_post_size is set to 24 MB so its not that.

Logging the list, we see only ~1100 elements make it into the list on the back end, with the final element in the list being truncated to only a few bytes of its actual value. Sometimes the final value still has part of its html encoding intact if the value contained characters like /. So it doesn't appear its truncating based on the number of fields, but rather the size of the request.

When this truncation happens, the user immediately gets an error in their browser showing ERR_SSL_BAD_RECORD_MAC_ALERT which I'm not sure the meaning of. No errors are logged within the server indicating anything went wrong.

If the user tries the EXACT SAME request a second time, it works fine. The issue is very sporadic and not easily reproducible and only seems to occur on very large requests.

This is driving us crazy. What are we missing?



source https://stackoverflow.com/questions/76114057/php-sometimes-truncating-post-requests

No comments:

Post a Comment