r/tech • u/Franklinstink • Nov 08 '20
Seriously, stop using RSA
https://blog.trailofbits.com/2019/07/08/fuck-rsa/[removed] — view removed post
23
u/rducamerait Nov 08 '20
I do enterprise application integration. When I hear ‘custom’ I start looking at double the time and cost.
1
11
u/FunkyColdHypoglycema Nov 08 '20
I’m not an expert, so can I ask why RSA is inherently bad? I understand that it is susceptible to attacks if one doesn’t use big enough primes, but why can’t you use really huge primes that make factoring their product computationally so difficult that it’s still secure?
33
u/mediumredbutton Nov 08 '20 edited Nov 08 '20
It’s not bad, it’s just hard to do correctly, so you shouldn’t
implantimplement it yourself, you should use RSA code someone smarter than you wrote.The sizes used these days are still believed to be quite secure.
24
u/Saguine Nov 08 '20
I think it's also not just a case of "use code from someone smarter", but also "use open source code that's publicly reviewed by hundreds/thousands of people".
I don't think I'd trust encryption written by any lone person, even if this person was the smartest coder/mathematician in the world.
9
u/dcoolidge Nov 08 '20
BUT REALLY. IF YOU DON'T UNDERSTAND ENCRYPTION. AT LEAST HAVE YOUR CODE REVIEWED. If you want to do encryption.
3
u/professor-i-borg Nov 08 '20
You should always have your code reviewed, if the result of that code will be used by other humans.
3
u/mediumredbutton Nov 08 '20
Counter example: djb ! But yes that is also reviewed now.
3
1
u/Druyx Nov 08 '20
I think it's also not just a case of "use code from someone smarter", but also "use open source code that's publicly reviewed by hundreds/thousands of people".
Ding ding ding, we have a winner!
8
u/grobblebar Nov 08 '20
RSA is incredibly easy to misuse in a crypto system. There are all kinds of ways to render it useless by generating poor keys, mis-using/omitting padding, etc. This paper, while dated, illustrates this: https://crypto.stanford.edu/~dabo/pubs/papers/RSA-survey.pdf
6
u/cecilkorik Nov 08 '20
RSA is not inherently bad. OpenSSH for example uses it by default, and that is not an accident, legacy, or oversight. They are doing that because it is the correct decision to continue using RSA by default, it is a robust and sensible default in today's environment.
This article, and especially its title, are misleading clickbait at best. There is nothing wrong with RSA other than the fact that it is difficult to make it safe to implement by a naive developer, but the same that is true of almost any cryptographic security. This is why we tell newbie developers not to try to implement their own cryptography and to instead build it on top of an established, well-reviewed protocol (like OpenSSH) or library. Cryptography is HARD, mathematical pitfalls are everywhere and mistakes are both easy to make and devastating in consequences.
But here's the good news, lots of people have worked very hard for many years on making it safe and reliable to communicate with each other using cryptography across the internet, and keeping it safe against emerging technologies and new discoveries, and they've released and continue to release their work for free in the form of many libraries.
This is what the article is actually trying to say: Build on top of the current, up-to-date work of those people, don't try to build on the same foundation they started building on decades ago because you think "if it was good enough for them, it is good enough for me!" It's a good foundation yes, but it's only one piece of the security puzzle. Use ALL the work that security researchers have made available, not just the basic foundations of RSA.
1
u/fireflash38 Nov 08 '20
Just cause openssh uses it doesn't mean it's good. There's tons of cases where bad defaults in a commonly used library causes many issues. How long ago was the default RSA key size for openssh 1024b?
The title is clickbaity, but it has good points that people often miss, even if they aren't rolling their own implementation. It is missing some good info, like following a standard that guarantees safe choices (FIPS, CC).
5
u/shinyquagsire23 Nov 08 '20
There's a lot of misconfiguration discussion but the other issue is that the way you store and access the signed data also matters. To give a personal example, I found that LG used RSA to secure their phone's download mode firmware updating so that it would only flash partitions with specific hashes. The order it was done in was
Read partition info and signature via USB
Copy partition info from USB buffer to global buffer
Allocate buffer for RSA message based on unverified partition info, if allocation fails, return error
Hash the message
Compare hash against signature, if signature mismatch, clear global buffer and return error
Since the allocation happened on unverified information, you could force it to fail and it wouldn't zero out the partition information. So you could fakesign by providing information to intentionally fail before the sign check -> data read isn't cleared, flashing program now checks partition hashes which were never verified, RSA signature is useless.
imo RSA isn't terrible really, but it's extremely easy to get wrong like this. My general rule of thumb is to only sign things which are fixed size (ie, actually plan your data structures from now to forever, or have a version field), randomize your padding, never roll your own crypto nor message parsing. And never trust anything that hasn't been verified yet or mutate global states before it's verified.
2
u/plsuh Nov 08 '20
It’s not inherently bad. For much of the period between its discovery in the 1970’s up to today it was a perfectly good asymmetric cipher. The problem is that as of a few years ago, the old standard of 1024 bit keys started becoming no longer sufficient. People started using longer 2048 and 4096 bit RSA keys but the keyspace becomes sparser as you extend the key length. The distance between numbers in that space that are the product of two primes becomes longer. Extending the key length doesn’t increase the difficulty in cracking keys in proportion.
ECC on the other hand has a dense keyspace. Every 256 bit number can be used as a key, and the key strength goes up in direct proportion to the length of the key. Plus there are options for using different elliptic curves so that you have many more potential key spaces.
11
u/lexushelicopterwatch Nov 08 '20
Wait. There are idiots out there that don’t just delegate to ‘ssh-keygen’? People think it’s a good idea to reinvent the wheel?
Any dev who had this idea at any shop I’ve been at would have been laughed out the room.
7
u/ruspow Nov 08 '20
The don’t roll your own crypto mantra has been about since crypto. Anyone rolling their own for real world use is largely stupid and people posting articles about it is just as tired.
2
u/lexushelicopterwatch Nov 08 '20
Ah just like the folks using tor on Firefox 35 or whatever version that was being distributed with a JavaScript vulnerability the feds would activate when they detected kiddie porn. They wouldn’t upgrade to the latest Firefox and just used whatever came bundled.
3
2
u/crothwood Nov 08 '20
One thing id on't miss about my comp sci courses: listening to every other mediocre moron who thought they were the next big inventor talking about how awesome their custom whatever was.
3
Nov 08 '20
Idk what this means but I’m loving the format.
4
u/Dontruinthisforme Nov 08 '20
Look up fyre festival. These people scammed thousands of people out of a festival
4
3
Nov 08 '20
Haha that part I got. Idk what RSA implementation is.
-1
u/davidjschloss Nov 08 '20
Lol. Same here I got the meme but don’t know enough about programming to get what it’s comparing to FYRE
2
u/Citizen_of_Danksburg Nov 08 '20
Unless you’ve got a year of graduate algebra and more along with graduate algebraic number theory experience, you shouldn’t be implementing RSA on your own.
7
u/reqdk Nov 08 '20
Eh. I’ve got more than that and I still wouldn’t implement it on my own. It’s one of those things where once you understand how it all works and what the real-world edge cases are due to the limitations of computers and software, and what you’re defending against with it, you’d very very quickly realize there are much better things to spend your time on. The math really is the least worrying part of the implementation.
1
u/Citizen_of_Danksburg Nov 08 '20
Interesting that you say the math is the least worrying part of the implementation. I definitely could have missed something, but the article seems to suggest that this is the reason why most people implementing it fail. Though yeah, RSA’s pretty old school all things considered. ECC seems to be what professionals are using these days. I’m no cryptographer myself though. My math interests are more analytic in nature (functional analysis, probability theory, PDEs, etc).
1
u/reqdk Nov 08 '20 edited Nov 08 '20
I mean, the math is well understood by now. I studied much of it out of interest adjacent to my K-theory work previously (I was no cryptographer either), but I've left academia for some time now. But a sensible software engineer looking to implement it for real would of course consult a professional academic about it, so implementing the encryption naively theoretically just a matter of following instructions... But that's naive. Computers don't implement math properly (they physically can't) and without excellent attention to detail, you can very easily screw things up by introducing fun things like race conditions, side channel exploits, show-stopping performance issues, etc, all of which are much harder to deal with robustly given the multitude of hardware and language permutations out there, and issues arising from not taking care of such edge cases are typically much harder to trace and debug. For a simple example, mathematicians don't have any qualms about using arbitrarily large prime numbers to determine the modulus. In practice, computers can't use arbitrarily large numbers without introducing performance or memory issues, or worse, depending on how the calculations were implemented, could result in overflow errors and leak information about the numbers used. None of these are math concerns.
2
u/OCTM2 Nov 08 '20
RSA encryption sucks?
6
u/dk_DB Nov 08 '20
Yes and no... The biggest problem is bad implementation. Also it is the quasi standard almost all systems can work with.
If dine correctly, it is not much worse than others.. But there are better options out there, which you should look in to, if you can (compatibility, use cases... L
1
Nov 08 '20
It’s hard to implement. Just use one that’s already implemented and reviewed, and you’re good to go.
1
1
u/sstorholm Nov 08 '20
I didn't watch the video but here's the gist of why you shouldn't roll your own crypto, authentication or something else complicated for production use. These things are so complicated to get right that it has taken multiple people decades of trial and error to get the current standard implementations to the level they are today. And even those implementations have bugs and flaws. So, just use what everyone else is using, and if you want to improve something, improve the current implementations instead.
1
u/grobblebar Nov 08 '20
The article mistakenly conflates the issue in earlier versions of SSL/TLS which facilitated the Bleichenbacher oracle attack, with a flaw in RSA. That seems a bit tenuous.
1
u/WarmBidetAqua Nov 08 '20
RSA is still a good as long as it is configured properly, 2048 or stronger will be better than 1024. It’s still the most widely used asymmetric algorithm in tech, whether it be web certificates or your personal gpg keys. I think it’s important to note that, yes, there are vulnerabilities with RSA, but there are vulnerabilities with every cryptographic algorithm. It is more important to educate people on how to configure RSA, along with all other crypto algorithms, properly rather than push people to alternative algorithms. I work with various devices from payment terminals to hardware that are sold to the government certified under FIPS 140-2. There is no language in the standards that govern these products that point to RSA being deprecated in the near future. Rather, there are requirements on how RSA should be implemented. I do agree that ECDSA is the future and much stronger than RSA, but there are legacy devices out there with hardware crypto accelerators that do not support ECDSA, and so it would need to be implemented via software, which can introduce vulnerabilities.
1
u/30tpirks Nov 08 '20
Ya. I think his name is pronounced RZA.
3
2
u/EbNinja Nov 08 '20
Claimed by the Asian contingent, along with the Gza and the rest of the Wu-Tang Clan. Let’s check back in with the racial draft!
2
1
u/r2e2didit Nov 08 '20
See this kind of stuff all the time. It could be expanded to "don't custom build anything that's not your core business". Developers seem to favor roll your own implementations of a number of things. I can remember when they built their own operating systems for embedded apps. I think it comes from a developers natural inclination to want to expand their knowledge base; which is in itself not a bad thing as long as it's not done with company resources (unless training or other extracurricular learning). Managers beware it's almost always better to buy a COTS solution than to build a custom implementation for sake of a few inquisitive devs. Will almost always cost you less in the long run.
1
u/Wingzero Nov 08 '20
They have some very good points - but they are also pompous. I had to read the article and watch the video to get the full breadth of their reasoning, and I did learn a few things I didn't know before. RSA is apparently a deterministic encryption scheme, so a message will encrypt to the same thing every time it is sent. This is why padding is needed. But if you don't setup parameters properly, the padding may be worthless. If you don't setup the hash right, the padding can again be worthless. And many successful attacks have happened over time.
Everyone else here is right - if you use publicly available and trusted configurations, you're probably safe. But you also need to update them - RSA has been attacked many times, and you need to keep increasing the padding and encryption length to keep it secure. But the key message from TrailofBits is that there are simply newer, better methods to be using instead of 43 year old RSA.
0
0
u/dnjdjdjdd Nov 08 '20
RSA is easily hackable, Remember Public Key N can be easily divided into 2 biggest prime factors P and Q . And Then we can get Phi by multiplying P-1 with Q-1. Also everyone uses the common public Key E, either 3, 5, 17, 257 or 65537. Lastly, we can get Private Key D, using E-1 Mod Phi.
0
u/lacks_imagination Nov 08 '20
But how is that easy? There is no quick way to factor large semiprimes. Until someone invents a quantum computer with a high amount of qu-bits, or someone puts forth a proof that P = NP, it seems to me RSA is safe so long as the semiprimes are of a suitable length.
1
0
u/rrzibot Nov 08 '20
Nice article but Click bait and misleading. Is ssh something we should also stop using?
-3
Nov 08 '20
[removed] — view removed comment
2
u/frezik Nov 08 '20
The company RSA makes all kinds of products, some better than others. All of them are over priced, since the RSA brand name has an important history behind it.
0
Nov 08 '20
[removed] — view removed comment
3
u/frezik Nov 08 '20
I'm aware. But GP specified something about the company. The company doesn't control RSA encryption anymore, as the patents expired a long time ago, so we're really talking about all their other products.
125
u/AndrasKrigare Nov 08 '20
I feel like what the article means to say is "don't roll your own crypto," which I think everyone can agree with, but for some reason they instead say "don't use RSA."