Is it safe to store a sensitive data in Local Stoarge or session storage? Localstorage allows to any attacks for sensitive data

后端 未结 1 515
醉话见心
醉话见心 2021-02-19 11:36

In web application , How secure is local storage in Html5 or else is there any other way to secure the sensitive data in local storage.

Project Structure:

Front

相关标签:
1条回答
  • 2021-02-19 11:57

    There is something that every Webapp Craftsman must know:

    There is no repository beyond your firewall that can be fully secure. Why? Because the open door that you NEED to allow your application manipulate the data is accessible to everyone.

    Imagine that you decide to encrypt the content of the local storage.

    This will prevent someone with access to the browser's local storage (e.g. the developer tool) to be able to read/write the data. But how your application will access the data? You have two options:

    1. Send the encryption algorithm + passphrase within the client-side app. This will expose all your data if someone manage to read the code of your app and access to memory of the browser (e.g. the developer tool)
    2. Send every data from the client-side to the server to be decrypted there. Well ... this is pointless. Is better to store the data in the server for that matter.

    You can try as much as you want, you will need an open door, and that open door can be use by anyone.

    But I've a question for you: Do you really need a fully secure repository in the client side? This kind of repository weren't created for be fully secure, but they are secure enough!

    For example, the session cookie of your web app is stored by the browser right? And if someone steal that cookie, it can impersonate the user and your application will never notice it, right? This is pretty scary when you think about it.

    Nowadays nobody put to much thinking on this because browsers are secure enough to protect cookies from malicious access. And of course, they did the same to protect the local local/session storage, IndexedDB, WebSQL, etc.

    So, if your data is more precious than your user session, keep it in the server. If not, go ahead and put it in the browser.

    PRO TIP: Consider encryption when storing in a no secure repository to make it harder to get. But remember that this comes at a price: you will not be able to use the query system of those repositories to search over encrypted data.

    0 讨论(0)
提交回复
热议问题