Almost immediately after smugly declaring "mission accomplished", the bug reports started rolling in. Given all this, I disabled the feature and went back to the drawing board. Host keys handling has long been one of my least favourite parts of OpenSSH - the code is poorly tested, mistakes might catastrophically break host authentication and there are lots of overlapping and interacting features e.
So my first task was to improve the API to make it possible to solve the CheckHostIP interactions and add some sorely-needed unit tests for it well, at least of the code that I was going to be fiddling with. The abuse problem was more tricky - the attack was: a malicious server say, "host-a" could advertise the public key of another server say, "host-b".
Then, when the client subsequently connects back to host-a, instead of answering the connection as usual itself, host-a could proxy the connection to host-b. This would cause the user to connect to host-b when they think they are connecting to host-a, which is a violation of the authentication the host key is supposed to provide. The fix for this is to have the server prove to the client that it has the private keys that correspond to the public keys that it offers.
Unfortunately, this is a little fiddly since we don't want to have to calculate and send signatures for each of a server's host keys on every connection it's slow and expensive and we can't precompute the signatures otherwise a hostile server could just replay them and the above attack is back on. So I settled on a way for a client to ask the server to prove ownership of particular keys, allowing a flow like this:. The signatures proving ownership of the private keys are bound to the specific connection instance, so they cannot be replayed.
Unfortunately, this means that the hostkeys rotation support is a little less useful: it is not longer possible to offer public keys without having their private halves online to complete the proofs. I hope to bring this capability back in a future release, perhaps by ab using the certificate format to allow pre-computed proofs that are tied to specific hostnames.
The host key proof extensions are now committed to HEAD. Update 2: Jann Horn after Philipp Kern points out that a malicious server say, "host-a" could advertise the public key of another server say, "host-b". Then, when the client subsequently connects back to host-a , instead of answering the connection as usual itself, host-a could proxy the connection to host-b. This would cause the user to connect to host-b when they think they are connecting to host-a , which is a violation of the authentication the host key is supposed to provide.
The solution for this is for the server to prove to the client that server is in possession of the private key as well as the public. I'll add this before release or delay the feature , but it's going to make the key rotation more onerous.
Update 3: last one, promise. See the follow-up post. Something that's bugged me about the SSH protocol is its lack of key continuity - key algorithm changes and key rotations are basically unsupported, as there is no in-protocol way for a client to learn updated host keys for hosts that the user already trusts. This makes it difficult for users to switch away from weak public key algorithms like ssh-dss to stronger ones and makes it practically impossible for a host to gracefully rotate its hostkeys.
I'm ignoring host certificates here, which do solve the problem but are mostly useful within an organisation. These problems have become more urgent as the DSA supported in the SSH protocol has not aged gracefully, being within the range of a motivated attacker now.
I've wanted the SSH protocol to provide a way to get users onto better host key algorithms for a while and finally got around to implementing it a couple of weeks ago: OpenSSH 6. This fixes both the shortcomings I mentioned above: first, the client learns all the server's host key types, and can select the best possible host key algorithm ed is our current favourite on subsequent connections. Secondly, it allows a server to gracefully rotate keys by publishing additional keys for a period to allow clients to learn them, before removing the deprecated key s and letting the new ones become the primary ones.
The old keys, appearing first in the configuration, will be the ones actually used to authenticate the host to the client. This mechanism isn't perfect: first, it only works for users who actually connect to the server - if they don't happen to connect during the grace period when both old and new keys are offered then they will have to learn the new key manually afterwards. As such, it doesn't cope well with sudden key rotations e. Fortunately both these cases can be addressed with a bit of forethought: when setting up a server, generate some reserve keys.
Keep their private halves offline e. You could generate multiple sets of reserve keys if you like - you aren't limited to a single set. Please try it out! It's trivial though: a global request hostkeys openssh. In my biased opinion, its a small, easy to implement tweak to the SSH protocol that provides a significant improvement to the protocol. Once again their are proposals for mandatory retention of Australian Internet data to improve domestic surveillance. I think these are a terrible idea, both personally and professionally.
Here is a letter I just sent to my local parlimentarian and senator that explains my reasoning. If you agree, I encourage you to compose an email of your own or join one of the online campaigns like stopthespies.
OpenSSH 6. This turns out to be important because, even though your host's DNS resolver will connect you to the host that you intended, ssh doesn't know the full name for it. If ssh doesn't know the full name for a host then it can't reliably match it with a host key. The problem is even worse when the server is offering a certificate host key - these should contain the fully-qualified domain name FQDN of the server, but this break when users type " ssh bigserver " without the remainder of the domain name.
The other workaround for certificates of adding the unqualified names to the list of certificate principals is also terrible. One might be forgiven for thinking that the system resolver should be able to help us here; after all - it knows the FQDN for the destination host because it knows all the domain search paths the user configured and which one was actually taken.
Unfortunately, it turns out not to be useful for two reasons:. My solution has been to add explicit hostname canonicalisation options that allow the user to define their own optional DNS search paths in OpenSSH itself. You may notice that they substantially duplicate the search path functionality you'd expect to find in resolv. CanonicalizeHostname turns canonicalisation off and on it's off by default. CanonicalDomains specifies the list of domains to search for an unqualified hostname in.
CanonicalizeMaxDots sets how many '. CanonicalizeFallbackLocal specifies whether the original, unqualified name should be passed to the system resolver if it wasn't found in any of the suffixes in CanonicalDomains. This should all be more clear with an example. This enables canonicalisation with a single search path of mindrot.
When I type " ssh mail ", the hostname mail will be judged unqualified since it contains the no period characters specifically, less than or equal to CanonicalizeMaxDots , so ssh will try to resolve it in one of the CanonicalDomains.
If mail. It allows the user to specify rules for when the alias should be allowed to replace the original host name. Hopefully an example will make this clear too:. This example enables canonicalisation with a couple of suffixes in the search path. It also turns CanonicalizeMaxDots up to 1, so a name like mail.
If a name does not resolve in any suffix then it will be passed to the system resolver as a fallback. These options will be available in OpenSSH 6. I'd love to hear any feedback about them. I just belatedly rotated my PGP keys. The new key should be available from the keyserver network and is signed by my old key. As a very infrequent user of gnupg for anything but generating signatures, I found apache.
One thing that I noticed along the way that doesn't seem to be in the documentation. Where gnupg asks you for an expiry duration, it will actually accept an exact timestamp too. So you can answer something like T and it will do the right thing. Recently, I committed support for a new authenticated encryption cipher for OpenSSH, chachapoly openssh.
This cipher combines two primitives from Daniel J. Why another cipher and MAC? A few reasons First, we would like a high-performance cipher to replace RC4 since it is pretty close to broken now, we'd also like an authenticated encryption mode to complement AES-GCM - which is great if your hardware supports it, but takes significant voodoo to make run in constant time and, finally, having an authenticated encryption mode that is based on a stream cipher allows us to encrypt the packet lengths again.
Wait, what do you mean by "encrypt the packet lengths again "? Back in the dark ages of the SSH2 protocol's design, there wasn't consensus among cryptographers on the best order to apply encryption and authentication in protocols - in fact, the three main cryptographic protocols to emerge from the s - SSL, SSH and IPsec - all use different choices: SSL calculated a MAC over the packet's plaintext, appended it to the plaintext packet and encrypted and sent the lot - a construction now called "MAC then Encrypt" or "MtE".
Doing this allows an active attacker i. This unfortunately makes some forms of traffic analysis easier as the attacker can just read the packet lengths directly. OpenSSH takes some countermeasures to obscure the lengths of obvious secrets like passwords used for login or typed into an active session, but I haven't felt entirely comfortable with the protocol revealing the length of every packet sent on the wire. The new chachapoly openssh.
In addition to providing authenticated encryption with integrity-checking performed before unwrapping encrypted data, this mode uses a second stream cipher instance to separately encrypt the packet lengths to obscure them from eavesdroppers.
An active attacker can still play games by fiddling with the packet lengths, but doing so will reveal nothing about the packet payloads themselves - they can make the receiving end read a smaller or larger packet than intended, but the MAC will be checked and the check will fail before anything is decrypted or used.
Fortunately ChaCha20 is very fast and has quite small keys, so maintaining a separate instance is very cheap. We're not done yet though - an attacker may still observe the encrypted packets on the network to try to ascertain their length, and right now they are likely to be successful. I hope to add some features to frustrate this sort of traffic analysis some time next year.
Tuesday, 17 February Hostkey rotation, redux. Monday, 6 October Mandatory data retention in Australia. Dear Mr Thomson, I'm a resident in your electorate and am writing in regards to the proposed changes to the Telecommunications Interception and Access act to support mandatory data retention. The proposals would create a huge trove of information that service providers would need to keep absolutely secure.
Evidence suggests that this will not be possible. Consider the numerous security breaches of large financial institutions, the latest just last week at JP Morgan exposed the information of 76 million customers.
Financial organisations are subject to strong regulation, have a direct incentive to maintain the security of their customer data, maintain generally good internal controls, undergo frequent external audits and hold decades' of experience dealing with rogue insiders. Despite all of this, they are frequently broken in to.
Internet service providers have little to none of these factors in their favour. They generally maintain good security of their networks, but they do not have the skills, incentives or mindset needed to maintain the security of the highly-private data that is proposed to be collected. I would consider a breach to be inevitable - it might be an ISP employee checking on their spouse's browsing habits, an unethical provider selling the information or perhaps a foreign intelligence agency chuckling as they download the browsing habits of Australia As a citizen, I am appalled by these proposals.