1

For a hypothetical situation, imagine a program that saves its user's password, then automatically signs them in without prompting them for their password again. The password must be secured somehow, but if it were to be encrypted, wouldn't there then be an unencrypted password or key somewhere?

I know many programs that do this, but as I've been researching I've found no reliable ways to protect this data. Computer security is usually taken very seriously, with mathematically proven algorithms for most encryptions, ssl, etc. But with this, most of the advice I've found is to hide it somewhere in the computer, or to try to split it up or otherwise make it "difficult" to find. That doesn't sound like very secure advise.

Is there any way for a program to securely store a password, without anything left in plaintext, and without requiring a user to input a password? I'm sorry if this question is too open ended, but I would appreciate it if someone could at least point me in the right direction.

3

4 Answers 4

3

@Limit provides a good answer for web applications, but I'd like to answer your question for the general case.

E.G. you have an application, which you entrust with your password so it can sign you into other services. A good example would be your mail client(either on your smartphone or your desktop pc), which must store your username and password in order to authenticate with the mailserver. Another example of applications that do this would be web browsers which can store your login credentials for various websites.

These software agents need access to your plain text password, so the standard solution for keeping a password safe (password hashing) can't be used.

The short answer to your question in this case: You're entirely right, this isn't secure and your credentials can't be reliably protected (assuming you're not asked by the mail client / webbrowser to provide a master password, that is).

The longer answer: Some operating systems provide a kind of password safe, which is basically a file which contains the passwords, but the file is encrypted before storing it on disk.

In order to encrypt and decrypt, the operating system needs a key. It generates a random one and then encrypts this key with the password you use to sign into your operating system user account. Whenever you sign in, the password you entered is used to decrypt the random key. So this adds a layer of security (which can be circumvented by malware, but at least it's not enough to just look at the password file in order to steal your passwords). Of course, if you don't have any sign-in authentication configured for your os user account, this is pointless, because the OS won't have any secret from you to encrypt and decrypt the password file key with.

Operating systems which provide this password safe service for user applications are, as far as I know, in the minority. But there'a a few systems that work almost like that. For example, the KDE desktop environment on Linux provides such a password safe; it's not connected to your system user account password, so you need to provide an additional password, but just once per session. All software agents which use the password safe can then access their respective passwords.

(As an aside: Smartphone operating systems like iOS and Android provide transparent encryption of all your data on the phone. If you enable this, it works exactly like the system I've described for encrypting the password safe - your sign-in secret (e.g. pin code, password) is used to encrypt the master key which encrypts and decrypts the stored data)

1
  • Contrary to above, almost ALL major OSes provide keyring/keychain/password storage APIs that is unlocked by user password or master key. Most of these are well used by the OS (e.g. to store WPA PSKs) and by third-party apps (e.g. Chrome on all platforms).
    – billc.cn
    Commented Nov 29, 2016 at 10:46
2

I think you are confusing session management with this approach.

The programs which take user password as input and then log in the next time without prompting for password store a session identifier of the user in the client. This way, when the user makes a new request, it sends the identifier along with it and the identifier is refreshed as per the system design.

As for keeping it a secret, websites usually store them as a secure cookie in the browser and ensure that they are protected against cross site scripting and cookie hijacking to ensure the safety. Some websites refresh this token on every request to minimize the impact of a compromised session identifier.

0
0

To securely encrypt something with a password known only to an application, you must use the special API black_magic.AbrAcaDabrA(data_to_store).

More seriously the common use is to have a master password that is used to protect a strong random key that is used to symetrically encrypt the data. At that point, the data can contain anything including other passwords and can be securely persisted on disk between sessions. The only constraint is that the user must give the master password when starting a new session.

There are several variants of this. On Windows, the login password can be used as a master password for the native encrypted folders. Many browsers have this notion of master password to securely store other passwords and this master password is only asked once for any run of the browser, and all password managers I know also act like that.

But there is a strong limitation to this: you should only use it on a system you can trust. During the session, the application has to keep a secret in memory. It can be either the master password, the decrypted key, or the decrypted data. The last is seldom used because it will need to ask again the master password if data should be changed. But then, another program with admin rights can read that memory to steal the secret, and from there the whole data. Of course, the secret can be obfuscated with an inversible transformation, but it is only obfuscation, because it can be broken by reverse engeneering and we all know obfuscation is not true security.

Of course, typing a secret on an unsecure system immediately compromise it. But here the full password bag is compromised...

0

You cannot securely store passwords purely in software. But if you have a TPM or other hardware device like USB token it is possible to use a software which uses the devices to encrypt the data with quasi-non-extractable key. Worth to mention that Intel brought a technogy called SGX into Skylake which can be used to store and process data quasi-securely too. This "quasi" because you cannot protect your data from device manufacturer, because manufacturers often plant (and often document that) backdoors in order to make more money and comply with agencies' requests. If manufacturers, the agencies and their emploees are trusted then you are secure.

You must log in to answer this question.

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