Being primarily a front-end developer, I want to better understand the limits of server-side security with PHP.
Let's say I had an Apache server containing a MySQL database and only an index.php file. The (bad) design is as follows:
- A database containing private information, called "top_secret_database"
- A single table in that database, called "juicy_data"
- A column in that same table that has non-private, non-interesting information called "not_important_column"
The contents of index.php are:
<?php mysql_connect("www.example.com", "db_user_name", "foo") or die(mysql_error()); mysql_select_db("top_secret_database") or die(mysql_error()); $not_secret_column = mysql_query("SELECT not_important_column FROM juicy_data") or die(mysql_error()); echo "The password to my Top Secret Database is <strong>foo</strong>."; ?>
Obviously you can't peruse server-side code like client-side code, unless something went horribly wrong with the server or code (Can a client view server-side PHP source code?), and there are of course ways to keep even a hard-coded password safe(r) (Securing DB password in php).
However, my question today is, even if I outright told people my database password like in the index.php file above, what are the ways, if any, that an attacker can access the other (interesting) columns of the table that was just queried automatically by the above script?