Live data from Hacker News

Stanford Javascript Crypto Library

crypto.stanford.edu

81–90 of 91 posts

Re: Stanford Javascript Crypto Library

#81
This is a great library; I used it to build a Diffie-Hellman key exchange and symmetric encryption in an ASP.NET MVC4 app. The result is horribly insecure, but there is a situation where our product is installed under Http rather than Https that I solved.

If anyone is curious, it works just fine with BouncyCastle and RFC2989DeriveBytes (for PBKDF2).

Re: Stanford Javascript Crypto Library

#82
post #76
post #54

Earlier quoted context omitted.

If the server serving the HTML is pwnd, then it doesn't, but it doesn't really matter then, either. This protects against any external scripts being unexpectedly modified, e.g. someone MITM your jquery source.

If you don't allow external scripts to be modified, why host them externally at all? Why not just wget them and host them locally alongside the checksum document and skip all this silliness? Oh, also, those scripts can themselves load in other scripts you haven't checksummed. This is madness you're suggesting.

>> Why not just wget them and host them locally

Because you might be using a CDN for performance and bandwidth benefits.

If you relying on a third party piece of code that you allow to change at any time, then it is very difficult to do any release testing to give you a known set of conditions your application should work under.

Re: Stanford Javascript Crypto Library

#83
post #17
post #16

With the recent revelations that private internet companies (ISPs) are colluding with the NSA, I very much doubt the security of certificates issued by a "certificate authority". I really like the idea of Secure Remote Password (SRP) which uses a Diffie–Hellman-like key exchange instead of relying on third party certificates. The main difficulties I see to SRP adoption are: 1) Not all browsers natively support SRP, t…

I'm not sure how to engage with the idea that SRP is a viable replacement for certificate authentication; it only works with the client and server have a pre-shared key. I very much do not trust certificate authorities, but observe that you don't have to trust certificate authorities to make the security architecture of TLS work. Already, CA compromises have a minimized impact on properties like Google Mail, whose ce…

> it only works with the client and server have a pre-shared key

What "pre-shared key" are you referring to in SRP? The only a priori value needed for SRP is the safe prime (N) and generator (g).

Re: Stanford Javascript Crypto Library

#84
post #21
post #16

With the recent revelations that private internet companies (ISPs) are colluding with the NSA, I very much doubt the security of certificates issued by a "certificate authority". I really like the idea of Secure Remote Password (SRP) which uses a Diffie–Hellman-like key exchange instead of relying on third party certificates. The main difficulties I see to SRP adoption are: 1) Not all browsers natively support SRP, t…

This doesn't necessarily solve your problem, but new versions of Firefox, Chrome, Opera, and IE all provide CSPRNGs. It's experimental, but it's been available in Firefox for several versions. So if you have a modern browser, just open your console window, and try: window.crypto.getRandomValues(typedArray) On mobile, this random number generator is unfortunately not available on Android's browser, although it is avai…

I didn't know about the window.crypto.getRandomValues(typedArray). Thanks!

> And if you believe that's an intractable problem, then you should probably reconsider the use of any language for crypto that can be monkey-patched, including common server-side languages like Python, Ruby, and to a certain extent PHP.

Someone else in this thread mentioned http://www.defensivejs.com/ and I think it is going in the right direction.

Re: Stanford Javascript Crypto Library

#85
post #76
post #54

Earlier quoted context omitted.

If the server serving the HTML is pwnd, then it doesn't, but it doesn't really matter then, either. This protects against any external scripts being unexpectedly modified, e.g. someone MITM your jquery source.

If you don't allow external scripts to be modified, why host them externally at all? Why not just wget them and host them locally alongside the checksum document and skip all this silliness? Oh, also, those scripts can themselves load in other scripts you haven't checksummed. This is madness you're suggesting.

In what scenario do you want external scripts to be modified? Why not take advantage of their ability to serve the scripts while also verifying that they are the same scripts you expected to have? You can also verify that those scripts do not load any other scripts in the version you have. Then, if it's changed later to load more scripts, you'll know about it.

How is checking the validity of the scripts that run on your site madness??

Re: Stanford Javascript Crypto Library

#86
post #85
post #76

Earlier quoted context omitted.

If you don't allow external scripts to be modified, why host them externally at all? Why not just wget them and host them locally alongside the checksum document and skip all this silliness? Oh, also, those scripts can themselves load in other scripts you haven't checksummed. This is madness you're suggesting.

In what scenario do you want external scripts to be modified? Why not take advantage of their ability to serve the scripts while also verifying that they are the same scripts you expected to have? You can also verify that those scripts do not load any other scripts in the version you have. Then, if it's changed later to load more scripts, you'll know about it. How is checking the validity of the scripts that run on y…

It's... kinda madness. Just to be clear that we're talking about the same thing, here's the proposed process as I understand it:

1) load your loader script, which has the URLs, fingerprints of the scripts you want to run, and the necessary dependency information (jquery-ui must load after jquery for example). In the best case, this file is being served out by the same server that's hosting the HTML, that way at least you're not adding more attack vectors.

2) from the loader script, initiate ajax requests for each of the remote files you need

3) as you get each one back, validate that its signature matches those that are expected, raise an exception if it does not (ideally also displaying something to the user), and evaluating it if its signature matches and we've loaded all of its dependencies.

So, why is this madness?

1) Most of the time the reason that you're letting a third party host these files is for speed. They've got a CDN, and hopefully the file will already be cached by your user. Grabbing resources with javascript that you could load directly in the html will slow down your page's loading time, as the browser's html parser isn't able to look ahead and fetch resources that are likely to be needed before the renderer has asked (HTML has a defined rendering order that can be kinda strict sometimes, this is the same reason why you don't put your elements in the ).

2) Another reason for using a CDN for your JS libraries is convenience, which this process also wipes out.

3) The whole thing won't work at all unless the third party server sends back cooperative CORS headers, as you can't do an ajax request to a third party site without their cooperation.

Finally though – and this is the big one – it's more convenient for the developers, strictly safer, and faster for the end user if you just compile all of the JS and serve from the same domain that's serving your HTML. As stated above, if that server is compromised, you're toast anyways (barring a browser extension or similar). If you really want some more security, look into SSL (and actually look into it, there's definitely much better and much worse ways of doing it).

Re: Stanford Javascript Crypto Library

#88
post #86
post #85

Earlier quoted context omitted.

In what scenario do you want external scripts to be modified? Why not take advantage of their ability to serve the scripts while also verifying that they are the same scripts you expected to have? You can also verify that those scripts do not load any other scripts in the version you have. Then, if it's changed later to load more scripts, you'll know about it. How is checking the validity of the scripts that run on y…

It's... kinda madness. Just to be clear that we're talking about the same thing, here's the proposed process as I understand it: 1) load your loader script, which has the URLs, fingerprints of the scripts you want to run, and the necessary dependency information (jquery-ui must load after jquery for example). In the best case, this file is being served out by the same server that's hosting the HTML, that way at least…

Most of what you're describing as "madness" is already done in head.js and require. They have no particular speed penalties and handle dependencies better than just putting script tags in the right order. The one difference is that a system like this would check the hashes to verify the code.

The one possible catch, as you mention, would be getting access to these scripts before they are loaded without having cross-origin problems.

There are a number of problems with serving from your own domain. It is, in fact, much less convenient for developers, as it adds an extra step to the build process and requires the system to properly handle caching so that old resources are not still served after a build. It is also slower to serve from the same domain as there are connection limits. Lastly, it gives up all advantages of a CDN.

My proposal is an attempt to continue taking advantage of CDNs and third party resources, but without giving them the keys to your site. Did you ever consider that Google has access to all of your users' cookies, if they wanted to add a small modification to jQuery or Analytics? Considering recent revelations about government involvement, is it really out of the question to believe that they never would take that information?

Re: Stanford Javascript Crypto Library

#89
post #80
post #68

i built Masel with it (as a demo for our local javascript meetup) i.e.: http://replycam.com/m/ pretty much serverless encrypted message sharing. its MIT L. and unfinished https://github.com/franzenzenhofer/masel

Off-topic, but 'masel' is the Scots word for 'myself'.

i named it after the jidish http://en.wikipedia.org/wiki/Mazel_tov (written in german "masel tov") masel stands for "a drop from above". so basically "masel" as "drop" of privacy. but well i coded it during a train ride while i was drinkng some beer (reached the balmer peak with it http://xkcd.com/323/ )

Re: Stanford Javascript Crypto Library

#90
post #83
post #17

Earlier quoted context omitted.

I'm not sure how to engage with the idea that SRP is a viable replacement for certificate authentication; it only works with the client and server have a pre-shared key. I very much do not trust certificate authorities, but observe that you don't have to trust certificate authorities to make the security architecture of TLS work. Already, CA compromises have a minimized impact on properties like Google Mail, whose ce…

> it only works with the client and server have a pre-shared key What "pre-shared key" are you referring to in SRP? The only a priori value needed for SRP is the safe prime (N) and generator (g).

The password.
Post reply on HN