Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I store sensitive variables?

Tags:

c#

.net

asp.net

This is my first time working on a secure website. It's for a pet project I have.

For security purposes, where is it best to store information like SQL connection strings, database encryption keys, etc? Is it better to use web.config, store them in a class that accesses a database (like dataBaseHelper.cs or something), or somewhere else?

I intend to obtain an SSL cert as well. When communicating with the database, should I always use the secure connection?

like image 405
julio9 Avatar asked Apr 06 '11 02:04

julio9


People also ask

Where should sensitive data be stored?

Accessibility of sensitive data. For example, frequently used sensitive data is best stored on a high-speed medium, such as an HDD or SSD. If the storage media are in a data center, they are much easier to monitor for security and unauthorized access than if the storage media are in a cloud environment.

How do you save sensitive data?

How can I protect Sensitive Data? Encryption is the most effective way to protect your data from unauthorized access. Encryption can be defined as transforming the data into an alternative format that can only be read by a person with access to a decryption key.

Is it bad to store credentials in environment variables?

Not only is it bad practice; it's also very dangerous, especially if you upload your code to a public repository like GitHub. Then you just publicly present your credentials to anyone who comes across it! Environment variables collect all of our confidential information in a single file.


2 Answers

Check Encrypting sections of config files section on MSDN.

like image 198
Sanjeevakumar Hiremath Avatar answered Oct 20 '22 01:10

Sanjeevakumar Hiremath


Depending on the app, it's generally best-practice to use a KMS to store encryption keys. If a KMS is not available because of budget constraints or whatever, Key Containers are the next best option. Once your key is protected you can store variables either in encrypted sections of the config file as suggested, or as encrypted byte arrays in the assembly itself.

like image 32
lukiffer Avatar answered Oct 19 '22 23:10

lukiffer