Search code examples
c#.netwpfsecuritypasswordvault

PasswordVault security when used from Desktop app


I'd like to use Windows.Security.Credentials.PasswordVault in my desktop app (WPF-based) to securely store a user's password. I managed to access this Windows 10 API using this MSDN article.

I did some experiments and it appears that any data written to PasswordVault from one desktop app (not a native UWP app) can be read from any other desktop app. Even packaging my desktop app with Desktop Bridge technology and thus having a Package Identity does not fix this vulnerability.

Any ideas how to fix that and be able storing the app's data secure from other apps?

UPDATE: It appeared that PasswordVault adds no extra security over DPAPI. The case is closed with a negative result.


Solution

  • (this is from what I can understand of your post)

    There is no real way of preventing data access between desktop apps when using these kind of API's http://www.hanselman.com/blog/SavingAndRetrievingBrowserAndOtherPasswords.aspx tells more about it. You'd probably just want to decrypt your information.

    memory access restriction is difficult, code executed by the user is always retrievable by the user so it would be difficult to restrict this.

    have you considered using the Windows Data Protection API : https://msdn.microsoft.com/en-us/library/ms995355.aspx

    grabbed straight from the source DPAPI is an easy-to-use service that will benefit developers who must provide protection for sensitive application data, such as passwords and private keys

    WDPAPI uses keys generated by the operating system and Triple DES to encrypt/decrypt your data. Which means your application doesn't have to generate these keys, which is always nice.

    You could also use the Rfc2898DeriveBytes class, this uses a pseudo-random number generator to decrypt your password. It's safer than most decrypters since there is no practical way to go back from the result back to the password. This is only really useful for verifying the input password and not retrieving it back again. I have never actually used this myself so I would not be able to help you.

    https://msdn.microsoft.com/en-us/library/system.security.cryptography.rfc2898derivebytes(v=vs.110).aspx

    see also this post which gives a way better explanation than I can. How to securely save username/password (local)?

    If I misunderstood the question in some way, tell me, I will try to update the answer.

    NOTE that modern/metro apps do not have this problem, although they still are accessible in other ways.