1

A PHP based webshop running on a shared hosting stores libsodium encrypted personal data in it's MySQL database. To let users have access to their own data, a design very similar to the one discussed in this topic is implemented: a key is derived from the user's password (PWKEY), which is used to decrypt the user's private key (PRKEY), which is then used to decrypt the user's data.

There is a demand to introduce Login by Facebook/ Instagram/ Pinterest/ etc. and/ or other similar passwordless authentication services (for e.g. sending a login link to the user's registered e-mail) to the webshop. The problem is that without a password, this design is broken.

I am looking for a solution that would allow passwordless authentication while maintaining encryption keys in a manner that is secure and allowing users to decrypt their own data, but I have no idea how to approach this matter.

One might-be solution that came up was to add a second authentication layer: ask for a password/ phrase/ PIN separately right after the user logged in with the chosen authentication method, and generate the PWKEY from that password/ phrase/ PIN – but it would mean that passwordless isn't really passwordless...

0

1 Answer 1

2

The core issue is what security properties you want to guarantee. This kind of server-side per-field encryption does have some benefits, but only under fairly narrow circumstances: it does not protect the user when the backend is compromised since the backend still receives the key, but it would partially protect the user if your backend is vulnerable to SQL injection, or if an attacker has access to database backups, or if the database server is compromised, or if there is a bug in your software that would show another user's data.

I'd think about whether this encryption scheme is worth the added security. This will depend on the nature of the encrypted data and on your webshop's clients. It's kind of an odd choice since your scheme doesn't provide end to end encryption, and provides limited advantages over other security approaches. For example, you could get a very similar level of security by adopting these safety measures:

  • always encrypt database backups
  • set up your networks so that the database server cannot be reached from the internet
  • audit your backend to ensure that it contains no SQL injection vulnerabilities
  • have an automated test suite that verifies the logic in your backend

In case you do want to keep per-field encryption, then yes, passwordless log-in is not possible. However, not all operations might need access to the encrypted data.

  • you can use authentication services for user authentication
  • you will still have to prompt for the password when the key is required
  • you might be able to store the key beyond sessions on the user's device, e.g. in LocalStorage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.