The MySQL database connection part of the code emits error messages, which contain sensitive information about the server (eg. the file system path of the socket). Even if you disable display_errors, this is still displayed, though it should not. Here is a patch, which honours the display_errors setting and only emits the error message if the server admin's desire is to see error messages in the browser.

BTW this patch is against 4.4.x CVS, while this is also an issue in the HEAD version (but the install system changes are said to contain some remedy for nonexistent database connections). If it is desired, this can also be applied against HEAD.

Comments

ax’s picture

StatusFileSize
new1.34 KB

there are more places where sensitive information is revealed via error messages. see SQL error for bad URL parameters for an example. thats why i think this issue should be handled more generally than only fixing the mysql connection part. that is, /all/ errors should only be displayed if display_errors in php.ini is set. patch (incl. some s#"#'#g) attached.

gábor hojtsy’s picture

Ax's patch is complementary to mine. The error handler is registered way after the database connection is attempted.

Kjartan’s picture

Priority: Critical » Normal

What are the odds of the install system making it for 4.5? I am not really up to speed on its development. If the install system is ready for 4.5 I don't see a reason to apply Goba's patch yet.

Ax: care to make a separate issue for your patch and explaining why you remove error_reporting()? With your patch when display_errors is enabled it will also show @function, which indicates that any error SHOULD be ignored.

Steven’s picture

We now have our own toggle for displaying error messages or not, but of course it cannot be read with database access.

Still, I'm not entirely convinced about this patch. Installations with display_errors=off will offer admins no clue whatsoever as to what is wrong. Without these error messages, nothing gets logged at all (no watchdog possibility yet at that point), leaving admins no indication whatsoever of what went wrong.

gábor hojtsy’s picture

So then we can have either a one line error message in the die (but definitely not the mysql_error() output), or we can have a standard error.html shipped with Drupal, which is a friendly error message to the user. Steven, you complain about admins not getting to know about the error, but mostly end users will see such an error message, and not the admins, and they should not see the mysql_error() return value. Even if it does not contain sensitive information, it is far from friendly error handling.

BTW on Weblabor.hu, we solved this problem with HTTP redirecting the visitor to http://weblabor.hu/hiba.html (which is our error.html basically) in case of this low level database error.

Steven’s picture

Friendlier error messages and pages, okay. But I still think we should display the error string visually somehow, even to end-users. We cannot distinguish end-users from admins. I believe Drupal should offer enough meaningful information in every situation. Even if they can't understand what it means, at least they can copy-paste it so others can.

Otherwise we'll have to make a checklist of various things that can trigger a db error at that point, and paste it to anyone who asks about seeing such a vague error screen.

killes@www.drop.org’s picture

Doesn't apply anymore.

killes@www.drop.org’s picture

Status: Active » Needs work

still a patch

Jaza’s picture

Version: » 4.7.x-dev
Status: Needs work » Closed (fixed)

Issue no longer relevant, since error_handler() no longer outputs error messages directly, it outputs them via drupal_set_message(). Closing issue.