Imagine you have a private RSA-key on your computer encrypted (through PBKDF2, AES-CTR, HMAC256) with a password, now if the user would like to tick "Remember Password", what is the most secure way to save/remembmer the password? Obviously it's not storing it in plaintext in the local directory.

One option would be to use:

  • the HardwareID of the computer
  • the SID of the current user
  • the windows built-in EncryptFile (needs to be logged in as the same account)

Problem is that all of those informations can be compromised when you use the Utilman.exe Trick for example.

An alternative would be obfuscation, but we know that isn't really a solution for the long term.

Is there a proper solution for this or is this just bad practice?

  • 5
    What threat are we protecting against? Jun 30, 2014 at 16:34
  • Cache the result of the PBKDF2 instead? Jun 30, 2014 at 16:47
  • What threat are we protecting against? - Against an attacker on the PC who does not know the password but is using the local PC aswell. Cache the result of the PBKDF2 instead? In raw bytes? Is that good practice?
    – hl3mukkel
    Jun 30, 2014 at 17:59
  • @hl3mukkel, there's generally no way to keep passwords secure if you assume the attacker has root powers or can see your process memory. If you assume the attacker can only see what you store on disk, you can go the password manager route and encrypt the passwords with a master password that is required e.g. every reboot.
    – otus
    Jun 30, 2014 at 18:24
  • @otus okay, any idea how chrome or firefox manages this then? They never ask for a master password or something like that, are they really that naive to store the passwords in plaintext?
    – hl3mukkel
    Jun 30, 2014 at 19:31

1 Answer 1


Ultimately, if the machine can use the saved password without specific human intervention, then... it can use it. This means that an attacker who gains full control of the machine (either an hostile software hijack with Administrator/root privileges, or he grabs the laptop and runs for it) will be able to recover the password. On a theoretical basis, if you want to resist such an attacker, then you need the password to never make it to the machine RAM itself; you need some tamper-resistant component which does all the processing. This is the model of smart cards and payment terminals, which have physical shielding and actively destroy sensitive data in case of physical breach; and they have no notion of "root user" accessible to the actual human user either.

At best you can hope to slow the attacker down. Yet, there still are management methods which are better than others. For instance, when you store some sensitive secret value, you want to avoid letting leak to the backups, or at least with some specific protection. Similarly, the user may want to integrate such storage within a bigger secret management solution, e.g. a "password safe" with a master password, or things like that. Your best bet, then, it to rely on OS-provided services for storage of sensitive data. On Windows systems, this points to DPAPI. On Mac OS X, use Keychain. As usual, the software which is easiest to design and implement and deploy is software which has already been designed, implemented and deployed by somebody else. Thus, don't try to do more or less smart things on your side; just let the OS do its work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .