0

I'm building a webapp where I want to encrypt user data. I've done A LOT of research about this.

The main issue is that I want only users to be able to access their data. After reading countless articles and forums, I've come to the conclusion that the user has to encrypt the data in the client and decrypt it there too.

So the server never knows any key or anything, it only stores/retrieves encrypted data which is useless for an attacker or for me (the server/DB admin).

I have two concerns:

How to create a private key that never changes? The internet says using a key derivation function to create a key, but what about users that are logged in via SSO? They'll have no password, should I prompt them to create a PIN if they want to encrypt their data?

Where do I store the encrypted private key? Suppose I use a password-derived key, when the user logs in, I can store this derived key in the local storage of the browser. Now that's unsafe because an attacker that gains access to the browser gains access to the user's data, but I guess it's fine since that's the user's responsibility, so I'm not liable in case of a data breach/attack on the server.

I don't need details about what algorithm to use or what library, I need help with the flow of the encryption/decryption. This is my idea that have passwords (I'll maybe use the PIN idea for SSO users):

enter image description here

3
  • Have you looked at the models provided by open-source solutions for e2e? Like signal? These questions are generally answered in those models.
    – schroeder
    Commented Jan 16 at 12:57
  • There is no need for the server to derive data encryption key for you. Derive this key within the web app from the user password and hold it in memory until the user is active. When the user closes the tab, it should re-prompt the user for the password in new session.
    – defalt
    Commented Jan 16 at 13:15
  • I would advise that you expand your research into search terms that include "end-to-end encryption" because all of these issues are solved problems. francoisbest.com/posts/2019/…
    – schroeder
    Commented Jan 16 at 13:17

0

Browse other questions tagged .