I recently implemented the PEAR MDB2 package on my site, and I made an alarming discovery.
I have a User class. An instance is created when someone logs into my site. The constructor for that class creates an MDB2 connection and stores it in the User object. I am then saving that User object to a session variable so I can access its methods and properties from page to page as the user navigates the site.
The alarming discovery came when I did a print_r($_SESSION). Part of what returned was this (actual values changed to protect the innocent, and my database):
php Code:
Original
- php Code |
|
|
|
(
[username] => myUsername
[password] => holyCrapMyPasswordIsVisible
[protocol] => tcp
[port] =>
[socket] =>
[database] =>
[mode] =>
)
The dsn with my all my database login info is just hanging out there naked in the wind, completely exposed. This strikes me as being very, very bad.
I know I can rework my code to not store the MDB2 connection in the object so that it is not carried in the session. However, I'm still nervous that this information is so easily accessible. It makes me wonder if using MDB2 is leaving myself vulnerable to an easy hack.
Has anyone else noticed this? Is it as big of a security problem as it seems to be, or am I just being paranoid?