ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  The Practicality of OO PHP
Subject:   Security Concerns
Date:   2005-08-02 10:20:23
From:   rmartin
There are some key security flaws with this database example used here, that unless you take some strong precautions you'll be in a lot of trouble.
The example doesn't specially have a connection function (might have been left out for simplicity) but the reader might assume that its ok to put the mysql_connect method and all the password/login in the DataExtraction() (or in __construct() for php5). This is terrible because assuming common setup, I can simply
include 'http://www.yoursite.com/databaseextraction.php';
get_class_methods($this);

and then call your function. Even worse, I can now execute any SQL command I want considering the nature of mysql_query.
There are something’s that you can do to prevent this from happening, like:


1. Setup PHP to run as CGI and disable all read permissions http://us2.php.net/manual/en/security.cgi-bin.php


2. Ensure that you setup a SQL user that only has select permissions if that is all that user is going to be doing, and limit the views. Also, if the SQL server is going to be running on the same server lock the user access to the localhost http://dev.mysql.com/doc/mysql/en/user-resources.html


3. Use a separate connect function that stores the username and password outside of the main database class.


To you credit David, I understand that this is not a discussion on security nor do you make a claim this is how you should do it, but I just feel that it is important especially when creating tutorials for beginners that you pay class attention to security issues like this. More available at http://us2.php.net/manual/en/security.database.php



Thanks,
Roy
www.roy-martin.com


1 to 3 of 3
  1. Security Concerns
    2005-08-11 01:06:17  polarizer [View]

  2. Security Concerns
    2005-08-11 01:05:41  polarizer [View]

  3. Security Concerns
    2005-08-02 13:28:43  mr_peanut [View]

1 to 3 of 3