Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #4096 Security: Database connection errors report password to the browser
Submitted: 2005-04-07 16:52 UTC
From: tw at 6sys dot com Assigned: danielc
Status: Closed Package: DB_DataObject
PHP Version: 4.3.10 OS: Fedora Core 3
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 34 + 38 = ?

 
 [2005-04-07 16:52 UTC] tw at 6sys dot com
Description: ------------ Using PEAR::DB_DataObject 1.7.13, I put the full DSN in an INI file. The DSN includes the database password, of course. If there is a connection error (in this case, the database server went down), the first use of DB_DataObject results in an error message - raiseError() is getting called, which calls PEAR::raiseError(), which does kill the app (though the module docs seem to say the error isn't actually raised - confusing). This is all fine. But, when the error is raised, it's printed to the browser, and the error message produced by PEAR::DB contains the DSN, which contains the database password. So, when my database server went down, anyone coming to the site saw the database password. Reproduce code: --------------- In the .ini: [DB_DataObject] database = "mysql://user:pass@localhost/database" debug=0 ... In the code: ... $site = new RDBSites; // a DB_DataObject descendent. if ($site->get(1) != 1) die("Can't find the default site."); ... Expected result: ---------------- Returning FALSE from get() would be best, so I could handle the error myself. Dying with a descriptive error message output to the PHP log file with error_log(), and perhaps some user-friendly output to the browser like "Error connecting to the database," would also be fine. Dying with no error message at all would also be preferable. Actual result: -------------- Output to browser: DB_DataObject Error: [db_error: message="DB Error: connect failed" code=-24 mode=return level=notice prefix="" info=" [nativecode=Access denied for user: 'user@localhost' (Using password: YES)] ** mysql://user:pass@localhost/database"] (note the presence of the password)

Comments

 [2005-04-07 17:14 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-04-07 18:34 UTC] tw at 6sys dot com
Sorry, I misassigned the package - this is against DB_DataObject, not DB, so danielc's comment doesn't apply. Or if you meant it to apply - DB_DataObject::get() is not returning, so I can't check its return code; it's raising an error that kills the script.
 [2005-04-08 01:10 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-04-11 14:50 UTC] tw at 6sys dot com
Looks good. Thanks!
 [2008-05-30 09:29 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!