decates
decates

Reputation: 3535

Secure browser-side cache in Local Storage

To make the question clear: is the proposal below considered 'secure'? (i.e. doesn't introduce any significant security risks).

I haven't seen any clear reason why the following proposal would be considered completely insecure (as in, 'don't even bother', which seems to be the quick answer to anything with the words 'local storage' and 'secure' in the title). Fundamentally, it's based on the premise that: either you have access to the sensitive data in memory AND the cache, or you have access to neither.

The Starting Point

I have a web application which includes server-side web services and javascript running in the browser which calls those web services (securely, over HTTPS, that's not the issue here) and displays the data in the web page. Let's say it's an email application that displays your emails - i.e. it's sensitive data that you don't want to share with others.

A couple of points to note at this stage:

Up to this point, it's a standard web application, and I'm assuming that anybody reading would be comfortable that this is considered 'acceptably secure'.

Adding a Secure Cache?

The problem is: every time a user visits the site, their browser needs to download all of the (email) information, most of which is the same each time. Wouldn't it be nice if instead of needing to ask the server for all of the information each time, it could cache the data in the browser and check the cache. Bear in mind this is not 'offline' access: the browser is still talking securely to the server, but it may use data stored in a browser-side cache rather than retrieving it all from the server.

Here's the proposal:

Any thoughts?

For what it's worth, bear in mind that I have read:

(so I'm at least aware that the concerns around javascript + local storage + security)

Upvotes: 6

Views: 2878

Answers (1)

user1743173
user1743173

Reputation:

Security and cryptography is a environment where specifics really do matter and be aware that you've been very vague. Implementation is very easy to get wrong. If this is in a commercial application and data sensitive enough consider professional help.

However if you're going to try, ensure you're using a secure encryption cipher to encrypt your data otherwise you're going to open yourself up to attacks specific to your encryption method. Remembering that defaults are set for simplicity, not security. (Eg. ECB mode in block ciphers)

I would never recommend encrypting 2 identical texts with different encryption keys. Consider interlacing random text to make them not-identicle

Here are some attacks that systems like yours are generally vulnerable to:

  • Chosen-ciphertext attack
  • Known-plaintext attack
  • Random number generator attack
  • Ciphertext to plaintext length correlation

You'll also want to ensure that this encryption key is not vulnerable to XSS and other standard internet attacks.

Upvotes: 0

Related Questions