Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>(I suggest tagging this post "security".)</p> <p>First, you should be clear about what you're protecting against. Can you trust the client at all? A crafty user could stick a Greasemonkey script on your page and call exactly the code that your UI calls to send requests. Hiding everything in a Javascript closure only means you need a debugger; it doesn't make an attack impossible. Firebug can trace HTTPS requests. Also consider a compromised client: is there a keylogger installed? Is the entire system secretly running virtualized so that an attacker can inspect any part of memory at any time at their leisure? Security when you're as exposed as a webapp is is really tricky.</p> <p>Nonetheless, here are a few things for you to consider:</p> <ol> <li><p>Consider not actually using keys but rather HMAC hashes of, e.g., a token you give immediately upon authentication.</p></li> <li><p>DOM storage can be a bit harder to poke at than cookies.</p></li> <li><p>Have a look at <a href="http://code.google.com/apis/accounts/docs/OAuth2.html" rel="noreferrer">Google's implementation of OAuth 2</a> for an example security model. Basically you use tokens that are only valid for a limited time (and perhaps for a single IP address). That way even if the token is intercepted or cloned, it's only valid for a short length of time. Of course you need to be careful about what you do when the token runs out; could an attacker just do the same thing your code does and get a new valid token?</p></li> </ol> <p>Don't neglect server-side security: even if your client should have checked before submitting the request, check again on the server if the user actually has permission to do what they're asking. In fact, this advice may obviate most of the above.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload