views:

68

answers:

3

In a previous question I asked about weaknesses in my own security layer concept... It relies on JavaScript cryptography functions and thanks to the answers now the striking point is clear that everything that is done in Javascript can be manipulated and can not be trusted...

The problem now is - I still need to use those, even if I rely on SSL for transmission...

So I want to ask - is there a way that the server can check that the site is using the "correct" javascript from the server?

Anything that comes to my mind (like hashing etc.) can be obviously faked... and the server doesn't seem to have any possibility to know whats going on at the clients side after it sent it some data, expept by HTTP headers (-> cookie exchange and stuff)

+5  A: 

It is completely impossible for the server to verify this.

All interactions between the Javascript and the server come directly from the Javascript.
Therefore, malicious Javascript can do anything your benign Javascript can do.

By using SSL, you can make it difficult or impossible for malicious Javascript to enter your page in the first place (as long as you trust the browser and its addons), but once it gets a foothold in your page, you're hosed.

Basically, if the attacker has physical (or scriptual) access to the browser, you can no longer trust anything.

SLaks
+2  A: 

This problem doesn't really have anything to do with javascript. It's simply not possible for any server application (web or otherwise) to ensure that processing on a client machine was performed by known/trusted code. The use of javascript in web applications makes tampering relatively trivial, but you would have exactly the same problem if you were distributing compiled code.

Everything a server receives from a client is data, and there is no way to ensure that it is your expected client code that is sending that data. Any part of the data that you might use to identify your expected client can be created just as easily by a substitute client.

If you're concern is substitution of the client code via a man-in-the-middle attack, loading the javascript over https is pretty much your best bet. However, there is nothing that will protect you against direct substitution of the client code on the client machine itself.

Nicole Calinoiu
Well... the game industry does rely on cheat-blockers and has at least a bit success with it, but of course that stuff is quite intrusive (OS drivers, rootkit-like, etc.)... its disappointing that there is no easier way, and no way for web-development at all...
apirogov
None of that actually allows the server to ensure that the expected client code is running. It simply makes it more difficult to substitute an alternate client since there are more verification points to simulate.
Nicole Calinoiu
A: 

Never assume that clients are using the client software you wrote. It's an impossible problem and any solutions you devise will only slow and not prevent attacks.

You may be able to authenticate users but you will never be able to reliably authenticate what software they are using. A corollary to this is to never trust data that clients provide. Some attacks, for example Cross-Site Request Forgery (CSRF), require us to not even trust that the authenticated user even meant to provide the data.

Chris Clark