News for hackers. Stuff that matters.
Re:Show HN: A decentralized social network with end-to-end e... by tptacek on Friday January 08, 2016 @08:00PM (#10869505)
The cryptography in this system does not appear to be safe. Apart from the fact that it's browser Javascript, which can only be as secure as the server's verified TLS key anyways (and thus doesn't add any security TLS doesn't), it's also using outdated RSA crypto constructions that are vulnerable to attacks.

I think you should find an expert to work on this project with you and provide the cryptographic design for you. Cryptography in a social network is like cryptography in a messaging application: it has to work. It's irresponsible to offer someone a solution for sharing secrets (with peers or with their network of close friends) if you can't keep those secrets.

Thankfully, you're not doing that yet; I think it was good judgement for you to include the "NOT SECURE" warning in the Readme.

Good luck!

Re:Show HN: A decentralized social network with end-to-end e... by mschultheiss on Friday January 08, 2016 @08:11PM (#10869541)
Yes, as written on top this is a technology preview, so it is not safe yet. Furthermore the production version will use the web crypto api. The client software must be shipped packaged as a standalone application (Apache Cordova etc.) with integrity protection or hosted on your own server and served via https. Yeah, the goal is actually to get some feedback about the crypto design and improve it :)
Re:Show HN: A decentralized social network with end-to-end e... by tptacek on Friday January 08, 2016 @08:15PM (#10869559)
Unfortunately, the Web Crypto API doesn't automatically get you safe cryptography either. It was added by the W3C to allow video vendors to implement content DRM in pure Javascript rather than requiring plugins, and so it includes a great deal of legacy crypto.

Long story short, you need an expert in cryptography to design this for you, whether or not you use WebCrypto.

This isn't something you should take risks with. It would be better to advertise a decentralized social network with NO CRYPTOGRAPHY (which is what this essentially is) than to say it has "cryptography that hasn't been audited" (which most users won't distinguish from real crypography).

Re:Show HN: A decentralized social network with end-to-end e... by mschultheiss on Friday January 08, 2016 @08:59PM (#10869699)
1. The web crypto api was indeed made to secure communications, such as stated by the W3C on http://www.w3.org/TR/WebCryptoAPI/ (...) "Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications. "

2. Yes, you are definetly right, an detailed audit of the protocol is necessary by more than one expert.

3. Here is a short description of the basic concept: Client and server are seperated. The client software is basically what is hosted on Github. Its source code must be protected from MITM attacks of course, so it is best to ship it as standalone, downloadable application in the final release. THE CLIENT CODE WILL NOT BE OFFERED BY A SERVER IN A PRODUCTION VERSION.

So at sign up, the client software now generates a (RSA) public key pair and some symmetric keys used for (AES) encryption and integrity protection locally and encrypts it with a passphrase. The passphrase is only known by the user, but not by the server. The encrypted string is also integrity protected. It is sent to the server, stored there, and decrypted with the passphrase at login again. This way we ensure only the client software can see secrets, such as the private key, but not the server software.

Next, you have a key directory. It is signed after every modification with a secret salt which was generated by the client (and not known by the server) at signup. The keydirectory contains all the verified public keys of the user. (Protecting it from replay attacks would be worth another essay here) Now when you write messages for example, you get the public key from this directory and encrypt/sign it basically like in PGP. So the focus of this preview is not on the crypto primitives, but rather on the concept itself.

Edit: I hope this does not sound too unfriendly, I am very happy about your feedback and I promise I will look for further advice regarding the crypto/protocol ;)

Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Friday January 08, 2016 @09:42PM (#10869843)
> 1. The web crypto api was indeed made to secure communications, such as stated by the W3C on http://www.w3.org/TR/WebCryptoAPI/ (...) "Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications. "

So they say. You'd be hard-pressed to find a cryptographer that likes Web Crypto.

> 2. Yes, you are definetly right, an detailed audit of the protocol is necessary by more than one expert.

Shameless plug: https://paragonie.com/service/code-review

> So at sign up, the client software now generates a (RSA) public key pair and some symmetric keys used for (AES) encryption and integrity protection locally and encrypts it with a passphrase. The passphrase is only known by the user, but not by the server. The encrypted string is also integrity protected. It is sent to the server, stored there, and decrypted with the passphrase at login again. This way we ensure only the client software can see secrets, such as the private key, but not the server software.

Are you going to build it in, say, Electron? That's pretty neat.

What padding mode are you going to use for RSA? What hash function for MGF1?

Are you going to also employ digital signatures? Will you use the same RSA keypair for signatures?

What about your other parameters? (There are attacks for e=3 RSA signatures, for example.)

What cipher mode are you going to use for AES? What key size? Are you going to MAC then Encrypt, Encrypt and MAC, or Encrypt then MAC? I'm assuming the third option.

How are keys going to be authenticated to the clients? How will they detect/prevent the server from substituting a user's RSA (eww) key for one of their own choosing?

How are you going to derive your encryption keys from the password?

Why not save a lot of time and frustration and just use node-sodium (assuming Electron of course)?

    - Transport: crypto_sign() + crypto_sign_open()
    - Encryption: crypto_box() + crypto_box_open()
    - Key derivation: crypto_pwhash() + crypto_box_seed_keypair()
      + crypto_sign_seed_keypair()
    - Salts, keys, nonces, etc: randombytes_buf()
Life is easier with sodium. https://paragonie.com/blog/2015/09/how-to-safely-implement-c...
Re:Show HN: A decentralized social network with end-to-end e... by Canada on Friday January 08, 2016 @10:41PM (#10870003)
Even if he makes all those decisions correctly the system won't support forward secrecy.
Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Friday January 08, 2016 @11:08PM (#10870059)
Why do you think I separated crypto_sign() from crypto_box() in my description?
Re:Show HN: A decentralized social network with end-to-end e... by jchrisa on Friday January 08, 2016 @09:50PM (#10869860)
It seems like there would be a lot of uses for something like a jQuery for the WebCrypto API. There are enough ways to get it wrong, and enough commonality among 80% use cases, I can see something like this being better than the alternative.
Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Friday January 08, 2016 @09:52PM (#10869865)
WebCrypto is a potluck of popular cryptography standards, chosen by committee.

What you want instead is a library that carefully selects primitives with an emphasis on:

    1. Security
    2. Performance
    3. Ease of use
You want a high-level API, like I'm building for PHP 7.1, not a low-level API, like openssl, mcrypt, WebCrypto, etc.
Re:Show HN: A decentralized social network with end-to-end e... by iheartmemcache on Saturday January 09, 2016 @11:17AM (#10871731)
Google's NaCL (i.e. NativeClient, not Libsodium-- awful overlap in terminology there) + Crypto_box + PPAPI seems to be really easy to implement as well as really secure, but Mozilla wants nothing to do with NaCL (again, the Google Native Client for Chrome/Chromium - not the DJB lib).

Edit: and that's what I get for skipping over half the posts in this thread. You specifically mentioned crypto_box/libsodium. No surprise there, you seem pretty well-informed from the 50% of the posts I did read in this thread ;). Zimmerman got it right amazingly right with PGP 20 years ago. The men and women at keybase.io are doing a great job trying to bridge the gap in the interim. Your route is the route I'm taking right now as I'm building out but with USB key and/or cell phone authenticators. Speaking of which, Thomas, in a few weeks if you have some spare time I'd love for you to look at what hopefully isn't a travesty of a product. (I minimized as much as I could re-using existing components with the intention of limiting the potential of bugs I could introduce, but Johnny's gonna have crypto soon if I have my way.)

Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Saturday January 09, 2016 @02:53PM (#10872592)
> No surprise there, you seem pretty well-informed from the 50% of the posts I did read in this thread ;)

Heh, thank you. :)

> Speaking of which, Thomas, in a few weeks if you have some spare time I'd love for you to look at what hopefully isn't a travesty of a product.

If he doesn't, feel free to ping me. ;)

Re:Show HN: A decentralized social network with end-to-end e... by jchrisa on Friday January 08, 2016 @11:03PM (#10870047)
Yes just something that implements signatures and private messages in the best way web crypto allows for. Bonus points for encapsulating the best practices rather than just documenting the footguns.
Re:Show HN: A decentralized social network with end-to-end e... by moron4hire on Saturday January 09, 2016 @05:09AM (#10870724)
2016 and using crypto as a lib is still so ludicrously difficult you still get advice to "get a crypto expert".

The failure of current crypto experts to create a usable crypto story is 100% why we can't have nice things.

Re:Show HN: A decentralized social network with end-to-end e... by rafael-rinaldi on Saturday January 09, 2016 @10:02AM (#10871433)
That's exactly what I think as well. It shouldn't be that difficult to get basic crypto to an application.
Re:Show HN: A decentralized social network with end-to-end e... by yk on Friday January 08, 2016 @08:23PM (#10869594)
Isn't this the one application were JS crypto is OK? As far as I understand, that is not at all, here JS crypto is used to offload the computation from a trusted server to a trusted client and afterwards the server distributes the encrypted message further.
Re:Show HN: A decentralized social network with end-to-end e... by mschultheiss on Friday January 08, 2016 @09:35PM (#10869815)
Yes, exactly :)
Re:Show HN: A decentralized social network with end-to-end e... by lucb1e on Saturday January 09, 2016 @05:31AM (#10870775)
> The cryptography in this system does not appear to be safe.

While one of the fundamentals, I think it's fair to say that swapping out cryptosystems is 0.1% of the work, or if the communication system needs to be redesigned, 1%. There goes a huge amount of work into designing and building all the rest.

Re:Show HN: A decentralized social network with end-to-end e... by iheartmemcache on Saturday January 09, 2016 @06:05AM (#10870840)
Whaaaaat. No way man. Especially if this gains critical mass before it's production-ready for whatever reason (who knows why Farmville and GroupOn hit when they did -- right place, right time) it's nothing short of irresponsible especially without a way to effectively declare the system compromised and pull the plug.

Not only that but there are real social implications in having a system that even drops the word "end-to-end encryption" in its phrasing with the whole "Why Johnny can't have crypto" adoption problem. The average engineer rarely reads the docs, my mom would never read the README.md despite the fact that it explicitly says it's not production ready. That bitter taste is left in ones mouth for years (eg. people still associate Microsoft with unstable, insecure junk a la WinME (or unstable junk like Vista RTM [SP1 was fairly stable, but Vista still is a joke]). If this is Johnny's first exposure to crypto and he's using it to Tinder girls on the side, he's never going to trust crypto again.

Push comes to shove rolling your own crypto is completely irresponsible. There are plenty of 'alternative internet' solutions out there that are doing the responsible thing and following the conventional protocols (i.e., using libraries that have been heavily vetted by those with graduate degrees in cryptography, have protocols to revoke/expire your keys in place, WoT's, etc.)

RE: Designing and building the rest -- just like one should use someone else's crypto libs, there are already tons of 'alt-internet' infrastructures that exist which do something similar. It doesn't have the novelty of a mobile app, but most of them do have the cryptographic security to make up for it. Just to name a few-- https://cryptosphere.io/ uses libsodium, https://github.com/okTurtles/dnschain is based on GPG and standard PKI, https://wiki.enigmabox.net/ (I've only audited the cjdns server but it looks real solid, granted my specialty of mathematics is a whole different branch so I'm not even close to an authority, other than I know enough not to roll my own). Then of course there's all of the Moxie-type projects out there which I'll be damned if they've got any holes in there, the dude is of DJB meticulousness

Edit: Yeah basically what Thomas said below me, re: the responsible thing to do is to advertise it as a product with no cryptography in place. Apologies for the knee jerk reaction, but secure communication is something I've felt awfully strongly about, as exhibited by my post history pretty clearly.

Re:Show HN: A decentralized social network with end-to-end e... by lucb1e on Saturday January 09, 2016 @07:46AM (#10871061)
> if this gains critical mass before it's production-ready

Yeah, that would be bad. Still, I think that with the warnings in place as they are, someone is going to notice and fix it way before that happens.

> my mom would never read the README.md despite the fact that it explicitly says it's not production ready

No, but anyone deploying it would. Your mom is not going to deploy this on her servers, is she?

Re:Show HN: A decentralized social network with end-to-end e... by mehrdada on Friday January 08, 2016 @10:10PM (#10869917)
> browser Javascript, which can only be as secure as the server's verified TLS key anyways (and thus doesn't add any security TLS doesn't)

This is not precise. While it does not stop even the most basic active attackers, it does prevent passive logging on the server without changing the served JavaScript, therefore making undetectable mass surveillance on the server harder. The effect is analogous to the difference between TLS with and without forward secrecy: with a similar argument you could conclude ephemeral DH/ECDH does not add any security to TLS, which is not quite the case.

Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Friday January 08, 2016 @10:13PM (#10869926)
> While it does not stop even the most basic active attackers

You just admitted that it's useless!

https://adamcaudill.com/2014/02/25/on-opportunistic-encrypti...

Re:Show HN: A decentralized social network with end-to-end e... by mehrdada on Friday January 08, 2016 @10:16PM (#10869932)
> You just admitted that it's useless!

No, I do not believe stopping passive attacks is useless.

Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Friday January 08, 2016 @10:18PM (#10869936)
When you stop passive attacks, then attackers will just step up their game to active attacks.

If you want to call something secure, you need to design a threat model that doesn't involve an attacker with one arm tied behind their back. That doesn't serve anyone's interests, except maybe the blackhats'.

Re:Show HN: A decentralized social network with end-to-end e... by mehrdada on Friday January 08, 2016 @10:22PM (#10869953)
> When you stop passive attacks, then attackers will just step up their game to active attacks.

Not always. It often changes the economics of the game. Especially when facing mass surveillance, considering the potential risk of detectability. Just because some attackers can step up their game for some targets, it does not imply they will do the same for all targets.

> If you want to call something secure...

I don't disagree with your point of view about what can or cannot be called "secure". One can debate that definition. However, stopping passive attackers is often NOT useless and it does add value. Security is not a binary proposition.

Re:Show HN: A decentralized social network with end-to-end e... by sarciszewski on Friday January 08, 2016 @10:30PM (#10869976)
Sure, but consider this:

Do you know what stops all passive attackers and most active attackers? TLS.

Do you know what WebCrypto adds that TLS doesn't? Nothing.

That's why this is useless. Just use TLS correctly and you're better off.

Now, reframe this as "desktop application that uses libsodium in a protocol designed by cryptography engineer" and suddenly my interest is piqued.

Re:Show HN: A decentralized social network with end-to-end e... by mehrdada on Friday January 08, 2016 @10:36PM (#10869996)
> Do you know what WebCrypto adds that TLS doesn't? Nothing.

No, consider this: an end-to-end encrypted messaging web page delivered over TLS that stores keys in browser local storage. A passive attacker that can see the incoming traffic on the server but does not want to alter the JavaScript sent to the clients will never see the messages. I argue this is weak but not useless.

(I would argue all TLS encryption in the browser is, in a sense, opportunistic to a certain extent, since very rarely people look at the address bar, effectively making it unauthenticated.)

Re:Show HN: A decentralized social network with end-to-end e... by tptacek on Saturday January 09, 2016 @12:00AM (#10870150)
Systems that stop only "passive" attackers simply aren't cryptographically secure.
Re:Show HN: A decentralized social network with end-to-end e... by mehrdada on Saturday January 09, 2016 @12:17AM (#10870187)
"Cryptographically secure" sounds like a vague thing you bring up here. To me, it sounds it is by definition secure (and cryptographically so, if they use cryptography) against passive attackers (and probably nothing else), but I am not really debating abstract and fuzzy definitions here.

My objection is very concrete: to say whatever uses JavaScript cryptography is as secure as TLS is false. Precisely, what it means is for all threat models imaginable, if you can somehow subvert TLS, you can always break the JavaScript crypto, and this is obviously false at least for one scenario I described in the other comment. We could reasonably debate the likelihood of the scenarios, but it's really hard to argue the mathematical equivalence of the two.

Re:Show HN: A decentralized social network with end-to-end e... by nyan4 on Saturday January 09, 2016 @05:17AM (#10870740)
> Apart from the fact that it's browser Javascript

Huge red flag.