How should I set up protection for the database against sql injection when all the php scripts are flawed?

Posted by Tchalvak on Server Fault See other posts from Server Fault or by Tchalvak
Published on 2011-03-02T22:01:49Z Indexed on 2011/03/02 23:26 UTC
Read the original article Hit count: 315

Filed under:
|
|
|

I've inherited a php web app that is very insecure, with a history of sql injection. I can't fix the scripts immediately, I rather need them to be running to have the website running, and there are too many php scripts to deal with from the php end first. I do, however, have full control over the server and the software on the server, including full control over the mysql database and it's users.

Let's estimate it at something like 300 scripts overall, 40 semi-private scripts, and 20 private/secure scripts.

So my question is how best to go about securing the data, with the implicit assumption that sql injection from the php side (e.g. somewhere in that list of 300 scripts) is inevitable?

My first-draft plan is to create multiple tiers of different permissioned users in the mysql database. In this way I can secure the data & scripts in most need of securing first ("private/secure" category), then the second tier of database tables & scripts ("semi-private"), and finally deal with the security of the rest of the php app overall (with the result of finally securing the database tables that essentially deal with "public" information, e.g. stuff that even just viewing the homepage requires).

So, 3 database users (public, semi-private, and secure), with a different user connecting for each of three different groups of scripts (the secure scripts, the semi-private scripts, and the public scripts). In this way, I can prevent all access to "secure" from "public" or from "semi-private", and to "semi-private" from "public". Are there other alternatives that I should look into? If a tiered access system is the way to go, what approaches are best?

© Server Fault or respective owner

Related posts about mysql

Related posts about php