133 points · by natejackdev · 9y ago · 69 comments
The reason it is described as "the world's most secure" is because both the code and the data are served from IPFS. IPFS is a content-addressable storage system, so as long as you access it over an IPFS gateway you trust (running one locally is the best way), you know the code and data haven't been meddled with.
It degrades to the same security model as ordinary encrypted pastebins when accessed over a gateway you don't trust (e.g. the hardbin.com public gateway).
This article (was on HN a couple of weeks ago) gives a good overview of IPFS: https://ipfs.io/blog/24-uncensorable-wikipedia/
And you can learn how to set up a local IPFS node here (it's super duper easy - copy binary into /usr/local/bin, ???, profit): https://ipfs.io/docs/getting-started/
So, please, don't knock it before you understand it :)
EDIT: Although I did try to explain it thoroughly in the About section, I do take responsibility for not making it easy enough to understand.
IPFS is pretty new technology, and presents a very different set of assumptions compared to traditional web apps.
If you didn't understand it at first but you do understand it now, please let me know what the key piece of information was that made it "click" so that I can put more emphasis on that next time.
I recommend reading Section 9.7 of Cryptography Engineering [1] to understand why choosing random elements from a set is harder than it seems. A good example of a similar bug is the nasty bug in Cryptocat's PRNG from 2013 [2].
I assume this step was done so the AES key could be included in the URL fragment, since a set of random bytes may not be url safe. I recommend feeding the random bytes of the key directly into the underlying cryptographic functions, and using a urlsafe encoding at a higher level when necessary.
Also, it appears you are using AES [3], a block cipher, but I cannot figure out what block cipher mode you are using. I'll have to dig into the CryptoJS code a little more to see what it defaults to, but I have a sinking feeling that it's ECB, which is completely insecure. Dan Boneh's Crypto I course on Coursera is a good way to learn the basics of block cipher modes.
[0]: https://github.com/jes/hardbin/blob/c77c2d7eb93586e0e009ea4b... [1]: https://www.amazon.com/Cryptography-Engineering-Principles-P... [2]: https://nakedsecurity.sophos.com/2013/07/09/anatomy-of-a-pse... [3]: https://github.com/jes/hardbin/blob/c77c2d7eb93586e0e009ea4b...
It's using CBC mode.
[0] http://incoherency.co.uk/blog/stories/hardbin.html
EDIT:
> And that would be in the best case, if it were sampling uniformly from the distribution - it is not.
Can you please point out how it's not? It's intended to sample uniformly. It would be non-uniform if it were "randombytes[i] % alphabet.length".
EDIT2:
I see now how it's non-uniform. 256 values in randombytes doesn't map 1:1 onto 62 values in alphabet. I will fix this tonight, thanks for pointing it out.
I understand that you're trying to balance the tradeoff between security and usability here, which is tricky. If quantum computers are part of your threat model, remember that Grover's algorithm provides a quadratic speedup for brute-forcing a symmetric key, so 2^190 would become 2^95 against a quantum adversary. Personally I prefer the margin of safety provided by using a full-strength 256-bit key :)
> It's using CBC mode.
Phew! That would've been truly catastrophic.
There is no sample from a set problem involved, just convert b256 -> b62, there is a correct way to do this.
For some reason you got lucky, and all of them are in this thread talking to you, attempting to give advice. Advice that some people pay a LOT of money for, to these specific people.
Most of your responses to them have read very defensively and argumentative. Out of everything said so far, this is the thing that scares me about possibly using this system.
It's frustrating when people act like I haven't thought through those assumptions and are handing out cargo-cult advice that is not applicable in this application.
The non-uniform key generation is a bug, and I'm glad somebody noticed it.
Had you come on with something reasonable and descriptive like "Hardbin: a security-focused IPFS based pastebin", you might have received a more tempered response (though still, I'm sure, skeptical - as with all things security-oriented).
What could possibly go right?
You don't exactly need clairvoyance to predict this outcome.
If you don't trust that IPFS is providing you with the correct content, then you also can't trust that it's providing you with the correct code.
If you don't trust the IPFS node, it could just ship off your decryption key to a remote server. There is no getting around trusting IPFS to work correctly. And if you trust IPFS to work correctly then there is no benefit to authenticated encryption.
But you can run your own IPFS node locally. Then you're only trusting it as much as you trust your local system. If you don't trust your local system then you can't trust anything.
- "Note that the security benefits of hardbin only apply when accessing it over a local (or otherwise trusted) gateway. If you access it over a gateway that you do not control, then the security model degrades to be equivalent to that of traditional encrypted pastebins."
- "The content will need to be pinned to make sure it stays around for long term (the same as any content stored in IPFS)." (though this doesn't impact the merits of its encryption)
- "You need to make very sure to use a known-good version of the code when creating pastes, as it would be trivial to create a malicious version that looks identical. The best thing to do is write down the hash the first time you use it, and always use the same hash. If you want to upgrade to a new version of the software, you'll need to update your hash."
- "I don't recommend using hardbin for highly critical stuff as the code has not been thoroughly audited by anyone but me."
The last is perhaps the most worrying thing.
I think the point is that it's an extraordinary claim with unextraordinary evidence.
Better, actually-trying-to-be-secure pastebin implementations will encrypt the data with JS before sending it to the server, and later decrypt it with a key that's embedded in the link's URL fragment (which the server never sees).
The security evolution here is that both the ciphertext and the code for the webpage to decrypt it are stored on IPFS, which is a content-addressed filesystem.
Thus, so long as you access pastes through a trusted (ie, local) IPFS note, the hardbin server operator can't insert code on the webpage after-the-fact to exfiltrate the key or plaintext back to them.
This is not an extra-ordinary claim. This is the claim of "I made secure software, and I reckon it's pretty good" wrapped up in the extremely ordinary common English-language hyperbole of calling something 'the best' when there is no way to know if it is, or prove it one way or the other.
Your data might be secure when is encrypted and never leaves your network.
Plus, the "world's most secure" would probably use HSM's at some point with real ones at server and smartcards w/ open standards at user side. I know a guy working to commercialize stuff like that. Stuff running on a vanilla stack w/ unvetted code and non-tamper-resistant hardware isn't most secure anything.
I assume if you used a third-party Tahoe-LAFS gateway instead of running your own, you would have the same security risks.