Secure ConnectionString in WinForm Applications

How can I protect my ConnectionString in a WinForm application?

+6
source share
3 answers

You can not. Although you can encrypt the connection string in the app.config file, the application should be able to decrypt it, and therefore you can always get an unencrypted connection string, especially with a managed application (maybe not for your regular end user, but any experienced developer can do this) .

The solution to this is not to rely on the safety of obscurity . Use Windows Integrated Security when connecting to a database using a Windows user account and granting the user the minimum amount of rights in the database.

Often this is not enough because it is very difficult to provide a sufficient database when end users are directly connected to the database (often because you need row-level security). To do this, you need to deny access to tables and views and completely return to stored procedures.

However, the best approach is to prevent the direct application from directly accessing the database; use the web service as an intermediate layer. In this case, you have full control over security, and you can safely store the connection string on the web server.

+19
source

Much has been set here ...

Encryption of sections and / or parameters in the App.config file to be redistributed

There was never a final answer ... it seems like this is one of those β€œlike it is” scenarios ... use what works best for your situation.

0
source

Source: https://habr.com/ru/post/895319/


All Articles