Hacker News new | ask | show | jobs
by scottlamb 19 days ago
The article is not about abandoning ssh (client) keys but protecting them from exfiltration:

> This post documents how I’m using various secure enclaves (YubiKey, TPM, Apple Secure Enclave) to hold/encrypt SSH key material and achieve the goal of not having any unprotected key material living on-disk.

Could you help me out and state the goal of your practices as simply as this? I can guess, but I'm really not sure, especially when you get into nftables checks for window sizes.

1 comments

My method reduces the threat of exfiltrated keys when someone or something manages to bypass the aforementioned methods without the need to purchase anything or use anything proprietary.

- One must connect from the correct address and with the correct TCP options.

So for example I could give you one of my ssh private keys and it would be entirely useless unless you were on my home internet connection using a device that emits my TCP options. (Or this could be a corporate SNAT pool or corporate VPN pool.).

Even the most clever MitM (man in the middle) attacks become significantly harder to perform. Leaks happen, I reduce the blast radius of the damage.

So if an attacker compromises your private keys, they’re already on your computer. If they’re on your computer, what stops them from connecting to your server from your computer? It would have the exact same TCP options, same IP address, same everything.

If I were an attacker that had an agent or RAT on your PC and got your private key, I’d first try to connect to your server on my computer. That would fail, but the very next thing I would do is use my RAT or agent to connect to the server via your own PC, because I would assume you had some sort of IP filtering in place.

If you store your keys in a trusted enclave like a Yubikey, TPM, etc it stops this cold (configured correctly).

So if an attacker compromises your private keys, they’re already on your computer.

They could be but I would not automatically assume that. Many stealers upload keys and do not install a RAT and there is no guarantee the RAT will function even if they manage to install one. If we want to go down every what if path I could make everyone want to power off their data-center and go home. If I showed everyone what SSH can do without any RAT's many would uninstall it. Involves multiplexing and one phishing victim to bypass MFA, HSM's, vaults, bastions, and does not leave a trace by design. No need to sneak past anti-virus.

Most orgs will not buy or implement an HSM so I am offering a soft middle ground that may suffice for some and may not even remotely be an option for others. Some orgs have no choice but to buy an HSM. Been there, done that. It can be a massive daunting task depending on what checkboxes are not yet checked and what requirements B2B financial customers are demanding. One of them required 6 different colored keys that get distributed to different org leaders and have to be put in the HSM to make any changes. They put the fear of diety into everyone about losing keys. One was lost. Thats when you find out that crazy expensive device is just hype.

Oh and ask me how many HSM keys I have seen pasted into Slack.

In security threat modeling, you only factor in things that you control when determining exploitability or risk. So for instance, when you say “a RAT might not work right” or “attackers don’t always use RATs” those aren’t things that you control, those are things that an attacker controls.

One of the principles of threat modeling is that you must assume an attacker is working actively to maximize their odds of success. Saying something like “well it would be annoying for an attacker to do this” is practically universally rejected by cybersecurity professionals especially in the age of AI agents.

I disagree that I am posing a bunch of “what-ifs”. The threat I am modeling here is how companies get compromised all of the time. Living off the land attacks as I’ve described is how companies large and small get hacked.

Furthermore, you do not need an expensive HSM. Most computers nowadays have secure enclaves (TPM) that can be used for this purpose.

Run a poll on HN some time and ask how many people are using an HSM. Out of the 17k visitors (or so on a given day) I would be surprised if it is over 500. That's ~17k not counting bots. Counting bots it's closer to 50k.

I suspect what you will find is that a majority of people are using SSH keys and a very relaxed firewall policy. A smaller number are using a bastion with some form of MFA + LDAP (if that) but it's all moot if the bastion or data-center servers allow multiplexing thus allowing log-less bypass of MFA, LDAP, HSM, etc...

A growing number are at least using a corporate VPN however more often than not those devices have a myriad of 0-days and are very poorly engineered over priced proprietary garbage full of state back-doors so at least buy the hardware made in your country so it may be your intelligence agencies that have access and a small sub-set of the MSS PRC.

Every Apple computer has a built-in hardware enclave. Just download Secretive, or you can install my macOS app, KeyMux, from the App Store, which supports SSH key agent protocol, GPG agent protocol, and PKCS#11. Or use the native command-line method discussed in the article.
You generally don’t need to buy a dedicated HSM. TPMs are built into a lot of modern motherboards nowadays. A lot of folks are probably unaware they have access to one.
> using a device that emits my TCP options

But what if you're connecting to a host using ssh keys that don't support all these extra options?

Just protect your keys in HSMs and all of this TCP mumbo-jumbo trying to pretend to be a secondary weak password becomes entirely unnecessary.
Everyone is free to choose what options work best for their needs and budgets. I would never attempt to inhibit anyone's choices. I use what has worked well for me and stifled red-team members.
Yes and you can change the protocol field in your TCP stack to run all connections over ip protocol 200 too, but it doesn’t add any security to your authentication system over and above your private key. What you are doing is the same thing; lots of extra too-clever-by-half complexity that doesn’t actually benefit you.

Key agreement protocols make sniffing the wire for credentials useless. Two seconds in wireshark and your hyper secure tcp options are toast.

I do not agree. I have used this exact method to detect all manor of shenanigans within VPS environments, dedicated server environments and corporate environments. Attackers stumble, fall and make a lot of noise trying to untangle my simple mitigations. I will keep it.
Why bother with the key? Anyone who has the right address and TCP options is obviously legit.
I enjoy listening to Michael Malice debate people mostly because he is a proud open troll. Sadly the numbers of people like him are dwindling but perhaps he will inspire people to come out of their shell.
?
"Security by obscurity isn't."
"Security by obscurity isn't."

Correct. Thankfully none of what I am doing is security through obscurity. It's actual security with a subtle scent of obscurity. If it was just obfuscation and you knew something, then you could do that something from somewhere else which you can not.

That's not security by obscurity, that's the Swiss cheese approach; which people attracted by purity frown upon but people attracted by practical solutions can live by.