What to Do
Encrypt all sensitive data.
Why
Sensitive user data can be compromised if stored in plaintext. Unauthorized access by users or attackers can lead to information disclosure.
When
All sensitive data should be encrypted.
How
To encrypt all sensitive data:
-
Identify sensitive information. Sensitive data is any information that is kept secret and should be disclosed only to authorized parties. Common examples of sensitive data include, but are not limited to, names of customers, government issued ID numbers, credit card and other financial information, passwords, and private keys. Sensitive data can be defined as follows:
- Information that either contains personally identifiable information or that can be used to derive personally identifiable information that should not be shared with others.
- Information that a user provides that they would not want shared with other users of the application.
- Information that comes from an external trusted source that is not designed to be shared with users.
- Some industries, such as health care and banking, have regulatory standards that define sensitive information. If any regulatory requirements apply to your application that define sensitive data, use those definitions.
-
Determine if storage is required. The safest thing to do with sensitive information is not store it at all. Examine how much information is stored in each case and how long that information is stored for. Determine whether the information needs to be stored. Any information being stored that does not need to be should be purged and the application should be rewritten to discontinue storage of the unnecessary information. When sensitive information must be stored, establish policies about purging it from both primary and backup storage, and ensure that they are followed. Be careful when using caches.
-
Store sensitive data securely. Choose the appropriate cryptographic mechanism for securing sensitive data and implement it.
-
Hashing. Hashing is appropriate for storing passwords. If your application stores passwords, hash and salt them for storage. It is recommended to use platform specific authentication controls for handling password storage. If custom authentication controls are required, passwords should be hashed and salted for storage. Hashing is not very useful for securing information other than passwords.
-
Encryption. Encryption is useful for storing all types of information other than passwords. AES-256 should be used to secure sensitive data that needs to be stored. AES-256 is implemented in the System.Security.Cryptography namespace.
-