I have a table that contains some sensitive data that I would like to secure further than the measures already taken. In the event of an intrusion resulting the attacker obtaining our PHP source code I want to protect some data in the database further.
Data has already been encrypted in the database, and encryption keys safely stored outside of the source code, but unfortunately these are only delays that will hopefully give us time to discover the intrusion and shut the system down. However, a reverse engineering of the code is technically possible.
As a fail safe I would like to limit select statements against a specific table. Our code should never have a need of retrieving more than one record at a time from the table. Is there a way of limiting the number of rows returned from a table from an administrative side of MySQL so that queries such as SELECT * FROM secure_data_table; are not possible?
The common way to do this is to DENY access to the table.
Create a stored procedure that selects one item from the table, e.g. by ID, and GRANT access to only that proc.