13 ms·
SSH gets protection against side-channel attacks
- baq 7y ago> Hopefully we can remove this in a few years time when computer architecture has become less unsafe. I think the author misspelled 'decades' here :)
- hvidgaard 7y agoBut why? For security critical software, like this, they should assume as little as possible. In essence you want to make the algorithms immune to side channel attacks when possible.
- bigato 7y agoBecause the more complexity you have in software, the harder it is to keep it secure. Even security mitigations can potentially introduce another vulnerabilities. This is one of the reasons that as a general rule we should strive for software to be kept simple.
- hvidgaard 7y agoGiven the nature of this software, it's natural to have mitigations against side channel attacks. They happen multiple times, and will happen in the future, no matter how secure we believe the hardware is. With that in mind, it's probably the better strategy to use slower and more complicated algorithms to protect the user. This would mean that when a side channel attack becomes known, if the algorithm already protects against it, nothing have to be done. Unlike if a fix needs to be made, you not face the problem you've outlined. I believe it's better to have a better baseline security at the cost of complexity, because it means less hotfixes needs to be released.
- bigato 7y agoSide channel attacks are only possible because the hardware is currently vulnerable. They are not a law of nature. Once you solve the vulnerability at its root and it becomes physically inexistent, and there's no more running hardware in the market that has such vulnerability, it would make no sense to keep such software mitigation.
- whatshisface 7y agoBusinesses still run mainframes from the 1970s - so, get ready to wait a century.
- bigato 7y agoWell yes, but that's a pretty special case. Those running such ancient hardware keep their own software and patches, and you don't see many software vendors supporting them unless their are being very well paid. OpenBSD itself does not support even VAX anymore, and developers felt pretty happy when they finally deleted large portions of specific code. Ubuntu is talking about dropping i386. Given enough time, the burden of supporting old hardware outweight the benefits for pretty much everybody, so it makes sense that it should fall on the shoulders of those who decided keeping the old hardware was a good idea.
- nickpsecurity 7y agoClive Robinson on Schneier's blog predicted lots of these problems after arguing they were a law of nature. He said any form of matter or energy connecting two machines might create a side channel. He said we'd have to clock all the inputs and outputs, make them predictable, and then "energy gap" the systems. We both already knew about CPU leaks since that was described as risky in 1990's. Sure enough, air-gap-jumping malware and processor leaks showed up. Later, getting a high-level view of hardware reinforced it was a law of nature. First, there's all kinds of RF leaks that attackers might pick up from normal operation. Second, most systems aren't fault/leak-proof if attackers actively hit the system with different physical effects or RF. Finally, each process shrink increases how easily chips, including mitigations on them, break. It looked like the stuff at 28nm was kind of broken by design with fixes and stuff built in to delay failures user would notice. This all sounds like the laws of physics are a huge obstacle to computers (a) working at all and (b) keeping secrets. Achieving (a) takes hundreds of millions to billions in R&D each year. I can only imaging what (b) might take.
- swinglock 7y ago..or forgot to add "/sarcasm".
- mtgx 7y agoI believe all consumer AMD Ryzen CPUs support Secure Encrypted Memory (SEM), but for some reason it's not enabled by default on most Ryzen devices/motherboards. It's a shame. I'd also love to see AMD bring an updated and patched version of Secure Encrypted Virtualization (there have been some attacks against it, although still fewer than against Intel's SGX) to consumer Ryzen in the near future. With so many cores available in consumer AMD CPUs (up to 16 now), people will start to use VMs more. Even Windows 10 has the easy-to-use Windows Sandbox now, as well as the App Guard sandbox for Edge. Not to mention they could use this as yet another "killer app" of their many-core CPUs, because otherwise people will eventually start to wonder why even get CPUs with so many cores over CPUs with fewer cores but higher singlethread performance. No different than say Verizon promoting high-quality 4k streaming on its new 5G network. I would've already preferred to see this in Zen 2, but at least Zen 3, which will otherwise bring few performance improvements and remain on the 7nm node, should come with these as some sort of "security-focused generation of Zen".
- chasil 7y agoIsn't AMD's encrypted memory meant more for the case of someone with physical access aggressively cooling a running system, then cutting power and removing the chilled memory for analysis (which will preserve contents much longer when cold than at normal temperatures)? The case of an attack on the SSH Agent would take place within the CPU, perhaps even in the same core on a separate HT/SMT thread, where the memory would be cleartext.
- captn3m0 7y agoDoes this support all Private Keys across all operations? Trying to understand the coverage.
- throw0101a 7y agoHost keys only, as those are the only ones that are long-lived. Session and cipher keys are ephemeral for forward security, and are rekeyed on a regular basis: see "RekeyLimit" in sshd_config(5).
- tr33house 7y agoAnyone with the actual link to the specific commit?
- mulander 7y agoSure: https://github.com/openbsd/src/commit/707316f931b35ef67f1390b2a00386bdd0863568 https://github.com/openbsd/src/commit/707316f931b35ef67f1390...
- archi42 7y agoHm, I wonder if the symmetric encryption with a sophisticated cipher is really necessary in this scenario. The aim is require an attacker to read 16Kb of memory in addition to the much smaller key data, e.g. for each bit of the key, the attacker needs X additional, random bits. Wouldn't it be possible to block-wise xor the random data onto the key? Maybe use a windowing mechanism, where the window is moved forward depending on the random data (e.g. for a 16 bit key, xor random bits 0 to 15, then move forward 4 to 16 bits, depending on the current window; iterate until the maximum number of window movements necessary to go over the whole random data is reached [leak less bits via timing]; if the end of the data is reached, again start at the beginning, but with some offset to avoid result_bit_0 = secret_bit_0 xor random_bit_0 xor random_bit_0).
- the8472 7y agoYou want every single bit error to avalanche to the whole key. You also don't want bit errors at some offsets modulo X to cancel each other out. Cryptographic hashes provide these properties. For any custom solution you would first have to prove that it has the security properties needed. The asymmetric crypto of a connection setup takes the lion's share of CPU cycles. I don't think it's worth the risk just to beat the cheap (relatively speaking) symmetric algorithms.
- ktpsns 7y ago- /* $OpenBSD: authfd.c,v 1.113 2018/12/27 23:02:11 djm Exp $ */ + /* $OpenBSD: authfd.c,v 1.114 2019/06/21 04:21:04 djm Exp $ */ what weird tool/infrastructure do these guys use, that they maintain CVS/SVN string identifiers in the files but nevertheless use git? I actually liked these identifiers. There were tools like ident (http://manpages.org/ident/1 http://manpages.org/ident/1) to deal with them.
- yjftsjthsd-h 7y agoUnfortunate that there's no commentary on performance impact. It's symmetric encryption on a few kB, so probably fast, but I'd like to have numbers.
- simias 7y agoIf I understand correctly it's effectively a one-time constant cost when setting up an encrypted connection, so it should be negligible unless you have a use case for setting up many extremely short-lived connections.
- mehrdadn 7y agoSSH has multiplexing [1] specifically to speed up multiple connections... would be interesting to know whether it incurs the overheads once vs. on every connection. [1] https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing
- LinuxBender 7y agoJust keep in mind that multiplexing makes phishing risks significantly higher. ssh wont log multiplexed auth and phished connections are auth free, up to 9 more sessions by default.
- mehrdadn 7y agoFar more important than that what I want to know is whether I should even care, e.g. is there any evidence of Spectre being used in the wild or not.
- bigato 7y agoA vulnerability that has been shown to work should not be patched in the software more widely used around the world to connect all kinds of linux/unix servers and even other systems? They should wait for it to start getting exploited "in the wild"? I'm just glad that the security of my systems does not depend on people with this kind of attitude.
- Koffiepoeder 7y agoRAM encryption for sensitive data is overlooked in so many applications, even "highly secure" applications like veracrypt [0] only recently started adding it. In my opinion server-applications of all sorts should encrypt their private keys by default; this makes cold-boot attacks and other memory-escape attacks so much harder, since now two totally unrelated memory chunks have to be combined in order to retrieve the private key (in fact one could argue that, the higher the quantity of memory chunks is, the harder it is to correctly decrypt the original private key; although to me this has the security through obscurity smell). In practice however, this is rarely done. OpenSSL for example has a whole lot of memory-management functions [1], but none of them seem to include RAM encryption (AFAIK it is not present in the source code elsewhere either, but it's a large one, so I am not familiar with all code. Related: in fact some people even argue it's way too large for it's own good [2]). Even better still, would be to use the CPU Cache for private keys, since this memory is even more difficult to access through any sort of cold boot. An interesting paper with much more information about this subject can be found here [3], to whom it may concern. [0] https://github.com/veracrypt/VeraCrypt/commit/321715202aed04dd9892d1c0686d080763ab212d https://github.com/veracrypt/VeraCrypt/commit/321715202aed04... [1] https://www.openssl.org/docs/man1.1.0/man3/OPENSSL_zalloc.html https://www.openssl.org/docs/man1.1.0/man3/OPENSSL_zalloc.ht... [2] https://queue.acm.org/detail.cfm?id=2602816 https://queue.acm.org/detail.cfm?id=2602816 [3] https://www.ieee-security.org/TC/SP2015/papers-archived/6949a003.pdf https://www.ieee-security.org/TC/SP2015/papers-archived/6949...
- spacephysics 7y agoIf I were writing a cryptographic algorithm in C++, how would I ensure the CPU cache was used for private keys? Would it have to be written in a lower level language, or does there exist a library for C/C++?
- Zarathustra_ 7y agoPrevious thread with lots of relevant information: https://news.ycombinator.com/item?id=8542405 https://news.ycombinator.com/item?id=8542405 Short answer is yes usually, and if not, you can always do inline asm. Of course, you're really, really, really not supposed to write your own crypto.
- jnordwick 7y agoCouldn't they also move the keys around in memory to every second or keep the bytes of the key separated (this seems like it would be similar to encrypting)? These side channel attacks even under ideal conditions take a very long time and part of the problem is they basically need to guess at memory addresses. Even when data is in a known location, it is sketchy. Anything that slows down locating data would help immensely.
- knorker 7y agoDoes this only protect the SSH host key? What about the session keys for the sysadmins who have logged in, and maybe keep their session up 24/7?
- throw0101a 7y agoSession keys are rotated. See "RekeyLimit" in sshd_config(5).
- foobar_ 7y agoTake my money!
- gnomewascool 7y agoGreat! You can donate to OpenSSH[0], whose "funding is generally done via the same donation framework" as the rest of OpenBSD, to which you can donate either directly[1] or via the OpenBSD Foundation[2]. If you're serious about donating obviously please check that these links are legitimate and I'm not a scammer. (I'm not affiliated with OpenBSD in any way.) [0] https://www.openssh.com/donations.html https://www.openssh.com/donations.html [1] https://www.openbsd.org/donations.html https://www.openbsd.org/donations.html [2] https://www.openbsdfoundation.org/donations.html https://www.openbsdfoundation.org/donations.html
- foobar_ 7y ago50$ donated! I hope that's good for some beers :) On a sidenote paypal donation took way too long. If anyone is interested in making open source donations simpler feel free to ping me.
- chasil 7y agoFor your donation, you also received preliminary code for quantum-resistant key exchange. $ sed -n '/NTRU/,/enabled/p' ChangeLog sntrup4591761x25519-sha512@tinyssh.org using the Streamlined NTRU Prime 4591^761 implementation from SUPERCOP coupled with X25519 as a stop-loss. Not enabled by default.
- nabakin 7y agoIs this only for OpenBSD's implementation of SSH?
- chasil 7y agoIf we wait long enough, it will go all the places that the portable release at openssh.com pushes it. It will take a few service packs, but even Windows will get it. C:\>ssh -V OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
- mehrdadn 7y ago> Attackers must recover the entire prekey with high accuracy before they can attempt to decrypt the shielded private key, but the current generation of attacks have bit error rates that, when applied cumulatively to the entire prekey, make this unlikely. It seems the real mitigation isn't the prekey size, but the temporal sparseness of the symmetric key -- since I would've imagined attackers would just try to obtain the symmetric key rather than the prekey. Weird to see they they didn't even mention this... I imagine attackers would try to find a way to get the symmetric key to stay in memory for a while.
- the8472 7y agoThe prekey is hashed into the symmetric key. Both the hash function and the symmetric cipher have avalanche effects that mean that N bit errors require the attacker to bruteforce 2^N combinations. unprotected RSA keys on the other hand have structure and are dense in memory. That means fewer bit-errors and and the ability to guess the missing bits faster than O(2^N).
- mehrdadn 7y agoYeah but my concern was about direct leakage not brute force. That's what Spectre is about.
- the8472 7y agoOh yeah, but the temporal sparseness doesn't just apply to the symmetric memory encryption key. The most important part is that it also applies to the asymmetric host keys, which are the actual thing one wants to have protected. prekey -(hash)-> memory key -(decrypt)-> host private key
- repolfx 7y agoI think the assumption is the symmetric key can be stored in AES-NI registers that aren't susceptible to RAM based side channel attacks?
- ajaurio 7y agoCould password managers like 1Password (AgileBits Inc.) employ similar techniques? They seem to make very little effort in this regards. E.g. on 1Password, https://discussions.agilebits.com/discussion/101551/article-just-published-in-washington-post-is-saying-1password-and-others-have-security-flaws https://discussions.agilebits.com/discussion/101551/article-....
- eridius 7y agoThis kind of mitigation really only makes sense on shared machines (such as servers). On a desktop OS, if an attacker is in a position to read memory from other processes, it's pretty much game over already. Browsers implement Spectre/Meltdown mitigation on desktop OSes because without that, JS could read secrets from other JS contexts executing in the same process. One of the mitigations is in fact to just segregate JS contexts into different processes depending on the domain they belong to. But most apps don't execute untrusted code so most apps don't have this sort of in-process attacker to worry about.
- sedatk 7y ago> On a desktop OS, if an attacker is in a position to read memory from other processes, it's pretty much game over already. Not really. Password managers have access information to your other accounts in the cloud. Your desktop may not have your most valuable data.
- deleted 7y ago[deleted]
- doomjunky 7y agoNo. I just tested KeePass. 1. I created a new test-entry with a long and random password. 2. Opened the process's memory in the HxD hexeditor. 3. Ctrl+f 4. Found this password 4 times. Even after i locked KeePass i still found the password 2 times. This is bad!
- Too 7y agoHere is a study on how well various password managers try to scrub their memory to avoid RAM dumps: https://www.securityevaluators.com/casestudies/password-manager-hacking/ https://www.securityevaluators.com/casestudies/password-mana...
- jasonh3 7y agoWhen I first saw this post, I got excited that someone had finally addressed the side channel from 17 years ago, which gathered inter-packet timing from ssh packets (and the fact that passwords are not echo'd) to a) detect when passwords were being typed, and b) use Hidden Markov Models to extract keystroke timing to try to extract the likely passwords. There have been defenses proposed over the years, but none were accepted by OpenSSH AFAICT. https://users.ece.cmu.edu/~vsekar/Teaching/Spring19/18731/reading/SideChannel_Song.pdf https://users.ece.cmu.edu/~vsekar/Teaching/Spring19/18731/re... https://www.researchgate.net/publication/2907598_Timing_Analysis_of_Keystrokes_and_Timing_Attacks_on_SSH https://www.researchgate.net/publication/2907598_Timing_Anal...
- wahern 7y agoThe proper defense is to not use passwords. It's 2019, nobody should be using passwords on SSH-enabled shell accounts. Heck, I use secure tokens for authentication so this memory encryption hack is useless to me--even I don't know what my private key(s) are, nor does OpenSSH or any other software on my computers. But I appreciate that we're a long way from ubiquitous hardware-based authentication.
- gnur 7y agoAfter you are connected you might still want to enter a password (for sudo perhaps).
- rphlx 7y agoThe solution there is to have the app use line buffering rather than a "raw" term mode that exposes inter-char timing on the network. How widely that's followed in practice, I do not know, but one would certainly hope that sudo does it.
- rphlx 7y agoIf you really cannot use keys, then one mitigation is to use copy/paste to paste the entire password instead of typing it one character at a time. That can open some copy/paste vulnerabilities e.g. in X11 where any app can then read the password until you copy something else in its place. And a network observer may still determine the password length. But it closes the inter-key timing channel that permits direct character recovery.
- vaxman 7y agoKrypton Authenticator app anyone? https://krypt.co/docs/security/privacy-policy.html https://krypt.co/docs/security/privacy-policy.html
- Klasiaster 7y agoIt could use the x87 floating point register stack to store the encryption secret. These registers are not used unless there would be some assembly in the SSH libs that accesses them.
- Liquid_Fire 7y agoWouldn't they be saved to memory anyway on a context switch?
- Klasiaster 7y agoYes, but I thought this is done in kernel space and a userspace attack has no access to that while the syscall is served.
- Liquid_Fire 7y agoThat is true - it's probably more secure than storing them in the process, but several of these side-channel attacks can apply to kernel space (depending on hardware and security patches applied). It's also not portable - OpenSSH runs on non-x86 architectures, and they might not have spare basically unused registers lying around. Finally, I'm not sure the x87 registers have enough space to fit these keys. You have 8 80-bit registers, for a total of 640 bits. Your typical SSH private key might be 2048 bits or more. So it's a fun and creative line of thinking, but probably not practical in this case.
- sedatk 7y ago> Hopefully we can remove this in a few years time when computer architecture has become less unsafe. Narrator: It hasn’t.
- rurban 7y agoI've looked at it. There's still a spectre window of opportunity to get the shielded private host keys. sshkey_shield_private => explicit_bzero() openbsd-compat/freezero.c https://github.com/openssh/openssh-portable/commit/4f7a56d5e02e3d04ab69eac1213817a7536d0562 https://github.com/openssh/openssh-portable/commit/4f7a56d5e... It's only using the insecure freezero, which is using the insecure explicit_bzero. A simple compiler barrier only, no memory barrier. so it's unsafe against the advertised spectre/meltdown sidechannel attacks, the secrets are still in the caches.