Skip to content

Bug in mod_security #778

Closed
Closed
@batata004

Description

@batata004

Hi,

I've been using mod_security for a long time and it's great but recently I discovered a bug that many customers of mine always complained but I didnt care. Today I decided trying to solve it and I discovered it's a bug with mod_security.

I am running Apache 2.4 in Centos 7 with the most updated version of mod_security installed using "yum install mod_security". The bug is this:

when a user tries to upload 2 or more files using any upload plugin (like valums or jquery.onprogress event) that send each file using a php POST request and my php file generates a random number with rand(0,999999) function from PHP library for some reason the number generated in all file upload is the same. When I disable the mod_security (adding # in front of LOADMODULE) the rand number is generated fine.

For example: if you try to upload 3 files using valums, for each file the plugin will request the script /server/php.php in the server trying to send the 3 files (I can see that with the Chrome developer tools F12). When the upload is completed my script under server/php.php generates a random number to save each file with a random number and this number happens to be exactly the same for the 3 files when mod_security is enabled. Is 3 files have about the same size the problems happens at about 90% of the time, but if the 3 files have very different sizes the problem does not happen and the random generated number is different.

I can only make this bug go away if I disable mod_security (which is not a good idea cause I recently get attacked in my server) or to generate the file names using microtime(true) cause doing so the file name will not be random but will have an incremental number according to the microtime it was processed.

I am sorry if I could not explain this bug clearer but I did not find any easier way to do so. If you need additional details I will be glad to provide. I hope mod_security community can help solve this bug or at least point me in the right direction explaining why the rand(0,99999) is generating the same number accross different requests done in a close interval of time

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions