Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cache password in JavaScript for later use, securely

We're currently developing a web-application that needs to decrypt data stored on the server with the user's password. The main goal is to not ask the user again for his password so the idea is, after login, store the password in a global JavaScript variable to have access to it later on when downloading and decrypting the files. Somehow I don't like the notion of keeping the password around, but from a marketing perspective the higher priority is convenience.

Am I just being paranoid or is this a possible security problem? If this could be a security problem, how can I implement this in a safe way that does not interfere with the convenience factor?

edit

Data is encrypted on the client when uploading and shall be decrypted on the client after the download. The user's password is stored on the server hashed with SHA-256.

like image 476
Robert Lohr Avatar asked Aug 23 '26 22:08

Robert Lohr


1 Answers

Have you considered using Session variables? They are much more secure.

And if you need to stick to client side JavaScript, I think you can store them in cookies.

However, I'm not sure what you are really trying to achieve for your app.

like image 153
J D Avatar answered Aug 26 '26 11:08

J D