Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How secure is ProtectedData.Protect (DPAPI)?

Suppose someone gets access all of my hard disk, I guess the weak spot would be my windows password. Without knowing/being able to retrieve that, the data should be pretty much safe, shouldn't it?

I'm asking specifically because of the EFS entry in wikipedia which states that

In Windows 2000, the local administrator is the default Data Recovery Agent, capable of decrypting all files encrypted with EFS by any local user.

and EFS happens to use DPAPI. So does the same apply to my own data protected using this:

ProtectedData.Protect(plain, null, DataProtectionScope.CurrentUser);

And if that is indeed the case, how could I prevent it?

[Edit] N.B. I'm trying to store credentials for a winforms app so that the user does not have to enter their password every time they login. In other words, if someone is able to login as that user (i.e. know the user password), then they might as well be able read the encrypted data.

Which - not coming from a windows background - now makes me wonder - can't the local admin login as any local user anyway? In that case I shouldn't be concerned about the admin being able to retrieve passwords anyway...

[Edit2] As google reveals, it looks like an Administrator cannot just login as any user without resetting/changing their password first. So my question still seems relevant...

like image 379
Walter Peel Avatar asked Jan 21 '11 06:01

Walter Peel


People also ask

Is DPAPI secure?

DPAPI protects confidential information using value data that is derived from a master key. A master key is a pseudo-random 512-bit number. Each user account has one or more randomly generated master keys. Each master key contains the data that is required to decrypt all the user's confidential information.

What is Windows DPAPI?

. NET provides access to the data protection API (DPAPI), which allows you to encrypt data using information from the current user account or computer. When you use the DPAPI, you alleviate the difficult problem of explicitly generating and storing a cryptographic key.

What is entropy DPAPI?

The entropy parameter "is optional entropy provided by the application that will be added to the key derivation [...] By default, DPAPI already uses different entropy for each blob, so in practice adding additional entropy does not [bold added] improve encryption security.

What is data protection on Iphone?

Data protection is an iOS feature that you use to secure your app's files and prevent unauthorized access to them. Data protection is enabled automatically when the user sets an active passcode for the device. You read and write your files normally, but the system encrypts and decrypts your content behind the scenes.


1 Answers

EFS uses DPAPI, not the other way around. And Administrator can't read your key just like that.

Before forgetting about DPAPI, I would consider the alternatives. If you encrypt the file yourself,

  1. You must select a strong algorithm and implement it well.
  2. You will need a key. Where will it be ?
  3. You will store the key in a file somewhere on your drive.
  4. That key is sensitive, obviously, you will want to encrypt it
  5. Goto 1

DPAPI does 1 to 3 well. 4 and 5 are moot. If a Windows password is not enough to protect data, ask yourself why it is enough to CRUD that data in the first place.

For better security, you can consider not saving the data but a (salted) hash of it, if possible. It makes your data write only, though. For example, if you want to verify a customer license number :

  • Save a salted hash value of it
  • Run the same hash on the salted license number you want to verify,
  • Compare the two. It they match, the license is valid.

If you must read back encrypted data and a locally encrypted key is not enough, consider encrypting your application key (step 2 above) with a private key stored on a smart card.

Either way, remember that things happens. You always need a backup key somewhere.

like image 150
ixe013 Avatar answered Nov 13 '22 16:11

ixe013