I have read somewhere that it is better to have two different MySQL logins in order to prevent hacking. What I mean is having one MySQL login for read access (SELECT permission) and another login for write access (INSERT, UPDATE, CREATE, and DELETE permission). Is it beneficial to have it setup like this and would it work with something like a PHP script?
|
Developers make bugs. One (sadly) rather common bug type in Web applications with PHP and SQL is SQL injections. A consequence of such a bug is that hostile outsiders can inject some arbitrary SQL code to be evaluated by the database. If you have two accounts to access the database and one of them only has read permissions, then any SQL injection bug in requests made by that specific read-only account will only grant read-only access to the attacker. That's like the inner doors in a submarine. These doors are designed to resist pressure and will be closed in case of emergency. That way, if the hull is pierced, then water will only flood part of the submarine, which will then sink slower, and the chances of survival for the crew will be greatly improved. Using separate read and write accounts for MySQL is the same kind of protection. You'd still prefer not to get hit by a torpedo at all, though; i.e. it is best if you do not allow SQL injections to happen, by using SQL properly (with prepared statements). |
|||||||
|
|
Difficult to follow, but have you considered something similar to MAC model The model is based upon, user or groups permissions are decided on clearance level and data classification levels. For e.g if the subject clearance level dominates the data-classification level (to a certain tuple in db) he would be denied entry. Rows are returned ONLY if there is a successful match of classification level and matching clearness level. What it means that a successful sql injection would give attacker only access to a sub-set of data or depending upon how the attack is executed in cases would return him absolute no results (privilege failure). You effectively cancel the attack surface through this technique. |
|||||||||||
|
