views:

60

answers:

2

Often in example code for software, I see a connection string eg. mysql://user@localhost in the configuration file for the software to get access to the database. This seems fine for a test/development server but for production, this seems very insecure. What is the correct way to do this in a production environment?

+1  A: 

That's pretty much the way it is on a production server as well. While it's a good idea to have the application access the database using an account that is as restricted as possible (e.g., it might not have permission to create or drop tables, schemas, databases, or might even be read-only depending on the application), if someone gains access to the application server they're pretty much going to gain at least that level of access to the database server - even if the authentication to the database is based on "trust" (i.e. some windows types of schemes), the attacker has access to the trusted host.

In past jobs, I've heard considerations of various obfuscation scenarios but ultimately they don't accomplish much.

zzzeek
Wow, I'm surprised that that's the best we can do. It is rather disturbing scenario...and I agree with you that obfuscation can only go so far.
Andrew Kou
+2  A: 

Your production server should be secured, no random users/people should have access to sensitive files - such as app.config with a connection string in it.

nos
My worry is when the server is compromised and someone actually does have access to the file.
Andrew Kou