Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#5024 closed defect (fixed)

MySQL backend exposes sql username and password on connection errors

Reported by: mc@… Owned by: Christian Boos
Priority: high Milestone: 0.10.4
Component: general Version:
Severity: critical Keywords: review
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

We recently had a hiccup with our mysql service in which python lost the connection. When this happened, the MySQL backend raised an exception showing the trace of calls that caused the exception. In this trace, the username and password for the sql database were exposed in plain text. i.e.

global MySQLConnection = <class 'trac.db.mysql_backend.MySQLConnection'>, path = u'/trac', user = u'trac', password = u'********', host = u'db.trac.sharpe-shell.org', port = None, params = {}

The error message received follows:

OperationalError: (2013, 'Lost connection to MySQL server during query')

This is a serious security issue. It seems as though some exception handling needs to be added in the SQL backend.

Attachments (1)

conceal_passwd-r5130.diff (1.9 KB ) - added by Christian Boos 17 years ago.
Conceal the password string so that dumping it in backtraces will not show its sensitive content.

Download all attachments as: .zip

Change History (5)

comment:1 by Christian Boos, 17 years ago

Description: modified (diff)
Milestone: 0.10.4
Owner: changed from Jonas Borgström to Christian Boos
Priority: normalhigh

comment:2 by Christian Boos, 17 years ago

Keywords: review added

What was the exact backtrace?

Were you using mod_python with the PythonDebug directive set to On, by any chance? If so, consider turning it off, see the mod_python docs.

Anyway, here's a possible solution for concealing database passwords, in general, attachment:conceal_passwd-r5130.diff. Please review.

by Christian Boos, 17 years ago

Attachment: conceal_passwd-r5130.diff added

Conceal the password string so that dumping it in backtraces will not show its sensitive content.

in reply to:  2 comment:3 by Matthew Good, 17 years ago

Replying to cboos:

Anyway, here's a possible solution for concealing database passwords, in general, attachment:conceal_passwd-r5130.diff. Please review.

First of all in the TracError you've left the "%s" in the string despite removing the parameter.

Secondly I think it'd be sufficient to simply return '' since revealing the length of the password also provides some information towards cracking it.

comment:4 by Christian Boos, 17 years ago

Resolution: fixed
Status: newclosed

Thanks for the feedback. Corrected patch committed as r5136 (trunk) and r5137 (0.10-stable).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.