Imagine that you have a web application that encrypts the user's data, such as a note or spreadsheet, on both the server and client.
The normal process for a user using this web application is something like this:
- The user logs into the application using a login/password-hash stored on the server. (Like normal web applications.)
- The user enters an additional secure key that is used to encrypt the client side data. The web application uses a client side encryption library such as SJCL
In this example let's just focus on the client side.
The situation is this: The server has been compromised and an attacker access to the server side keys. The attacker does not have the client side keys as they are never stored on the server.
Now the attacker needs to modify the Javascript to read the client side key when the user enters it in the web application (client side). The Javascript would be programmed to send the key to the attacker/server. Now the attacker has won.
I understand that it's assumed that once you take over the server, you've lost, but I would like to know if my thoughts below allow for a client side secure solution.
The situation
The HTML is assumed to contain some Javascript code inside some script tags, and there is also lot of Javascript code loaded via external Javascript files that reside on the server. It's the Javascript that runs the web application that is the problem. We have to assume that the attacker has modified any Javascript, be that inline or external.
Possible solution?
I want to be able to generate a hash of all of the Javascript loaded from my server. The has will act as a fingerprint for the client side Javascript code and the user will be wary of a new hash.
These are the two ways I have thought about so far:
Take a hash of all files loaded to the client. This means requesting all of the files included again.
Take a hash of all of the Javascript code in memory. (Can this even be done?)
The common problem with both options is that whatever function is actually doing this hashing, it needs to be small enough that the concerned user can verify it's safe to use within a few seconds.
I am thinking that this hashing function loads into the browser like normal, and the user can type the function name from the console without the ()
so they can see the code, and then type again with ()
to run the code.
Then the hash should be good enough for proving that the web application is in a state that the user knows they have inspected in the past.
This could even become a plugin at some point, although I am determined to see if a native solution is possible.
Essentially what I am asking is, what methods exist that allow us to prove the integrity of the client's state?