Home > > PHP, Suhosin and POST data

PHP, Suhosin and POST data

Last week one of my clients reported an issue showing some notices spilled by the application on their development and QA servers. After some regular debugging process, we noticed that the application is not receiving the complete POST data.

Solution was simple, open php.ini, check and increase the value for post_max_size. BANG!!! No change (ofcourse apache was restarted after change in ini). Some more time was spent debugging various things. Even the stupidest thing like whether browser is sending full data to server was also checked. But nothing helped. We again started scanning phpinfo for some help when suddenly we noticed that the servers were having Suhosin patch installed and active (suhosin.ini was a part of additional .ini files).

Suhosin is an advanced protection system for PHP installations. It was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core.

 

We started scanning phpinfo for Suhosin specific settings … EUREKA … we found the following -

suhosin.request.max_vars = 200
suhosin.post.max_vars = 200

 

Suhosin controls the number of variables that can be passed to a PHP script no matter what you set for post size in php.ini. The default value of this setting is 200 which means your PHP script will only see the first 200 values in $_POST array. All other data is silently truncated. We got this value increased to the one we needed for our script and everything was back to normal.

I spent quite a long time in finding and solving this issue and thus decided to quickly blog about this. Hope this tip will help someone save their quality time.

P.S.: Suhosin has lot of other configurations that may affect your scripts in some way. So, if you get into such a situation where everything looks normal in php.ini, look for Suhosin and its settings. You may find the solution to your problem just like I did.

Tags: , ,

  1. Amit Bhalerao
    February 17th, 2012 at 05:35 | #1

    I faced the the same problem yesterday (16 Feb 2012). Most of the form POST data was discarded even though the post_max_size was set to 300M.

    Having read your blog post just a day before, I quickly searched for “suhosin” in phpinfo.. and voila!! got it there active on the server. I changed the max_vars and the problem was fixed..

    You saved my time..
    Thanks Sir :)

  1. No trackbacks yet.