1

I could not get a satisfactory answer to my question on the google, they are:

  • How secure ConnectionString is over the HttpRequest?
  • Is using ConnectionString in web.config file more secure than using in any specific aspx page?
  • And how to secure ConnectionString for highly secure website?

I'm just curious to know about this.

12
  • Are you sending connection strings over HTTP? Commented Mar 28, 2012 at 13:02
  • 2
    web.config is safe, IIS will not serve this file to the client. Commented Mar 28, 2012 at 13:02
  • 1
    @AshwiniVerma: Note that encrypting might secure your web.config more but only for people who have anyway access to read it on the server. No configuration file will be sent via network. Commented Mar 28, 2012 at 13:12
  • 1
    @AshwiniVerma: Specify hacker. If this person belongs to the group which has read access on your server, your problem might not be solved ;) Commented Mar 28, 2012 at 13:26
  • 1
    That can help but it might be easier (if applicable) to use integrated security and not store username/password in cleartext at all. More important is to secure your network and server in general.(firewalls,service-packs/patches,minimum software,separate db and webserver, closed db-ports, ...) Commented Mar 28, 2012 at 13:39

7 Answers 7

8

You can encrypt the conenction string inside the webconfig, here is an article from Microsoft about this topic : http://msdn.microsoft.com/en-us/library/dx0f3cf2(v=vs.80).aspx

If you sending the connectionstring over a channel its not more secure than the channel. For example sending the connectionstring over HTTP and it will be just plain text, HTTPS and it will be encrypted, over FTP just plan text, and so on...

If you have a webapplication in a shared hosted environment you should be worried about that the provider maybe get hacked.

So just keep the connection string inside the web.config and encrypt it and don't send it around on internet ;-)

Sign up to request clarification or add additional context in comments.

2 Comments

in local connection you do not even need to encrypt it, just select Integrated Security=True <add name="OneConnection" connectionString="Data Source=localhost;Initial Catalog=TheDB;Integrated Security=True;" providerName="System.Data.SqlClient" /> Even if you read that, you have nothing to do it.
@Aristos: but it is not local server.
4

The connection strings are safe in the web.config. They are very secure unless you print them out on the web requests.

2 Comments

Could you explain a bit here, you probably meant something more, as I am sure you are well aware that storing plain text conn string in a web config is not drastically secure, as config file can be downloaded (through hundreds of vulnerabilities) remotely and read directly as plain text
@oleksii: yes you are right. that's why looking forward to now more about this.
3

Nice project on CodePlex Encrypt/Decrypt Connection string

Comments

2

There are quite a few methods to secure your connectionstring like

  1. Encrypt your connectionstring and save it in webconfig
  2. Encrypt your connectionstring and save it in windows registry

Its best to save connectionstring in webconfig to be used as a single point of use for whole application.

Comments

2

How secure ConnectionString is over the HttpRequest?

It is a string. It is only as secure as the connection is, so, normally not at all. This is assuming you are sending the connection string details over a HttpRequest. If this is not the case and your connection string is used in the web.config, it is as safe as the file itself and IIS are.

Is using ConnectionString in web.config file more secure than using in any specific aspx page?

No.

And how to secure ConnectionString for highly secure website?

Normally, one uses integrated security (windows authentication) to avoid hard coding of a username and password. Additionally, you can encrypt the configuration section, as described here (RSA) and here (DPAPI).

Comments

0

How secure ConnectionString is over the HttpRequest?

Do you send the connection string over http request ? Really ? what scenario it is ? Ususally only requests for a webpage travels thru http request and the response as well. Connectionstring is something your code internally use to access data and it stays in your server.

Is using ConnectionString in web.config file more secure than using in any specific aspx page?

Think about maintainability. If you put your connection string in a class, you have to rebuild your app when you have to change your connection string . If some body has access to your folder where you have your files, they can use a disassembler to see what is in your dlls.

And how to secure ConnectionString for highly secure website?

You can encrypt connection string in web.config. check this link http://www.codeproject.com/Tips/304638/Encrypt-or-Decrypt-Connection-Strings-in-web-confi

Comments

0

To answer your questions in turn:

  • How secure ConnectionString is over the HttpRequest?

You should never have to pass your connection string over HTTP; what usually happens is a user makes a request, your site processes the request including connecting to the database, and returns the result to the client. Connection String should not be sent over HTTP in this scenario.

  • Is using ConnectionString in web.config file more secure than using in any specific aspx page?

Depends on what you do with the connection string - if you ever write it out to the client then it's never going to be secure! The connection string is usually placed into config for reusability purposes; embedding it on every page makes for a lot more maintainance and potential bugs.

  • And how to secure ConnectionString for highly secure website?

You can encrypt the connection - so it is never stored as plain text, or use Windows Authentication so you never need a password. This is supported by ASP.Net as described here and here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.