#954 – Store Confidential Data Only Within SecureString Instances
November 20, 2013 3 Comments
You can use the SecureString class to securely store confidential text-based data.
The most important guideline, for security purposes, when using the SecureString class is:
Never store confidential data in a managed object (other than an instance of a SecureString)
If you transfer data from a SecureString into some managed object (e.g. a string or a byte array), the data will be less secure, due to the security issues with storing data in managed objects.
If you must work with confidential data in memory within your application, the proper procedure is to extract and decrypt the string data, but to store it in an unmanaged data structure (e.g. a BSTR). The data will be vulnerable while in memory within the unmanaged object, but you can then explicitly delete the data when done working with it, limiting the amount of time during which the data is vulnerable.
HI, great article :). As far as I know WPF or WinForms controls like TextBox provide Text property which is of string type.
How confidential data provided by user using UI should be handled? Is there any commonly accepted solution for this?
You can use the PasswordBox control, which stores its password in a SecureString (via the SecurePassword property).
Pingback: #956 – PasswordBox Stores Password as a SecureString | 2,000 Things You Should Know About WPF