Basically, my friend has an HTML form that includes a text area. Users should be able to enter any text (think paragraphs) into this field for entry into a database.
The company hosting this new site however, has mod_security installed and configured so that if a user enters any word reserved in SQL (inset, delete, describe, etc), the POST transaction is denied and a 500 error status is returned.
They claim that this is their standard (in order to block injection attacks) and refuse to change the configuration. They also claim that numerous other developers find their way around this.
I myself have quite a bit of experience in the PHP/MySQL world but have never encountered this with a hosting provider.
The only way around this I see would be to filter out the reserved words client-side through JavaScript - however I don't see this as a viable solution, because users with JavaScript disabled (I am a huge proponent of graful degradation & progressive enhancment) will simply be served an unusable form.
So my questions are:
1. Do you think the hosting provider is being a bit overzealous to not trust developers to do the proper filtering after the POST but before accessing/updating the database? 2. Do you know of a way around this that does not involve client-side manipulation of the input prior to the POST?
1. Yes, it certainly seems that way. 2. Sounds pretty impossible to change the input prior to POST without doing it on the client side.
Something like describe<span></span> might work, but that's just stupid. mod_security should be looking for the whole syntax of a query instead of a single word.
all you need is an array of the words you want to check for and an array of words you want to replace them with. In the opposite array order. check out Example 1697 on that link.
@kari.patila Thanks, I've recommended that they either get the hosting provider to make the needed changes to their setup, or go with a different provider. @jernigani - thanks for the suggestion, however, I don't think that this would be possible to do prior to the POST.