my application ( C#+SQL server) is running on the shared hosting. However, someone is able to access the database without permit. The connection string in the Web.config file, it had also been encrupted. Based on the above the senario, I have the following questions:

  1. Is the shared hosting not secure?
  2. Is the coding not really secure?

If the problem on the coding, what should I fixed? Many thanks!

------In Web.config, before encrypt------

  <add name="MyLocalSQLServer" connectionString="Initial Catalog=aspnetdb;
Data Source =; Initial Catalog =myDataBase; User Id =Username; Password =Password;" providerName="System.Data.SqlClient"/>

------In Web.config, After encrypt------*

<connectionStrings configProtectionProvider="MyUserDataProtectionConfigurationProvider">
  • share your code that do the connection stuff – Rami.Shareef Sep 21 '11 at 12:51
  • And you need to provide more details of how the person is able to access the database. Using your application? Using SQL Server Management Studio? Something else? – JohnL Sep 21 '11 at 12:56
  • Point 1 is a question that should be asked to your hosting company. – Ira Rainey Sep 21 '11 at 13:00
  • They decrypted the connectionstring and find the database location, username and password there. – Acubi Sep 21 '11 at 13:04
  • How do you know somebody has access to your database? If you have data that you really need to protect, shared hosting isn't what you should be using, because you cannot limit who can access the content. – Ramhound Sep 21 '11 at 13:08

Make sure that

It also makes sense to use a password generator create the user credentials, or a use long phrase (such as "correct horse battery staple") as the password.


If you're seeing unauthorized access to your database despite your web.config data being encrypted, then it's entirely possible that your database itself was compromised.

Most shared SQL providers allow remote connections, so someone could have brute-force attacked or otherwise compromised your database.

There are a number of best practices for securing a database, including:

  • Disable the SA account and create another user account to manage the database, or
  • Rename the SA account.
  • Use strong passwords or, as Jeremy McGee mentioned, long-phrase passwords.
  • Use separate users with limited, specific access according to role.
    • For example, you could create a user for your web site and grant it access to only the pertinent tables used by the web site.
    • One benefit of using multiple users is you can more easily trace the source of the compromise in the event it happens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy