-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StrictHostKeyChecking=no is insecure #696
Comments
For context:
|
Incidentally, the wording of that paragraph is quite misleading, especially: Also, semantically, what is a "strict check" anyway? The check is already done every time; strictness applies to policy enforcement. The option conflates two distinct concerns and should be divided into respective options: something like |
Can we narrow down the "everywhere" a bit so that it's clear what parts are problematic?
It seems to me that for So remaining are these 4 problematic cases:
|
I reckon that nixops should use All this is rather clunky, but I don't see a better way of doing it correctly, short of using some protocol-level ssh lib like paramiko to avoid the need to have the hostkeys on disk. I'm not too familiar with the nixops code, so I'm reluctant to attempt these changes without more input. |
This backend is a stripped down version of "none" backend without key pair generation / loading on the target machine. It instead relies on system/user SSH config for both authentication and host-key checking. This means that appropriate SSH keys needs to be added to targets manually. Related to NixOS#696 and many issues with SSH bootstrapping/recovery.
I've dropped this in vpsfreecz@c0affe0 completely to follow KISS principles and just use In vpsfreecz@510485d I've added a What do you think? Can revise these and create pull requests if it makes sense. |
That suits my purposes. I'm happy to manage everything ssh-related in Thanks for the effort in addressing this; I'd long forgotten about it. |
Probably it would be a better idea to add functionality for managing ssh host keys in However, I'd still set Regarding the |
I would use |
The correct solution is to set the hostkey in Nix configuration. Preferably automatically with manual overrides depending on the backend. Any mechanism which depends on StrictHostKeyChecking not equal to yes is flawed. I find it scary that anyone ever thought it was a good idea to implement it in the way it is currently working. It's basically a root kit on an infrastructure level for sufficiently motivated adversaries. If this would be more popular software, it would receive a CVE number. |
From issue #696: The hardcoded -o StrictHostKeyChecking=no everywhere is a big SecOps no-no. It's quite feasible an attacker could wind up with an IP address you neglect to change after relinquishing, and have an entire host config hand-delivered to him to inspect for vulnerabilities. He wouldn't be able to MITM the the deployment, but obtaining what is essentially a dump of the host's whole filesystem is still pretty disastrous, from a defensive standpoint. I by myself have been guilty of using this (added this to the Hetzner backend), because I did actually misunderstand the meaning of setting this option to no. My understanding was that it will refuse to connect whenever an existing host key is different from that in known hosts. However, this turns out to be only true for keyboard interactive or password authentication and if we're using pubkey auth, OpenSSH will happily connect. Now the real fix for this (already deploying with a pre-generated host key) is a bit more involved, but we can mitigate this for now, because since OpenSSH 7.5 there is the "accept-new" option to StrictHostKeyChecking, which does exactly what I thought "no" would do: If this flag is set to ``accept-new'' then ssh will automatically add new host keys to the user known hosts files, but will not permit connections to hosts with changed host keys. Signed-off-by: aszlig <[email protected]>
Okay, I did actually misunderstand the implications of setting this to |
Okay, Hetzner does have an API enpoint to query the host key of the rescue system: https://robot.your-server.de/doc/webservice/en.html#get-boot-server-ip-rescue-last I've added aszlig/hetzner#32 accordingly to get this into the library so we can make use of it via NixOps. |
Thanks @aszlig. The more backends we have, the better the cloud environment becomes. Somewhat related to this is using |
From issue NixOS#696: The hardcoded -o StrictHostKeyChecking=no everywhere is a big SecOps no-no. It's quite feasible an attacker could wind up with an IP address you neglect to change after relinquishing, and have an entire host config hand-delivered to him to inspect for vulnerabilities. He wouldn't be able to MITM the the deployment, but obtaining what is essentially a dump of the host's whole filesystem is still pretty disastrous, from a defensive standpoint. I by myself have been guilty of using this (added this to the Hetzner backend), because I did actually misunderstand the meaning of setting this option to no. My understanding was that it will refuse to connect whenever an existing host key is different from that in known hosts. However, this turns out to be only true for keyboard interactive or password authentication and if we're using pubkey auth, OpenSSH will happily connect. Now the real fix for this (already deploying with a pre-generated host key) is a bit more involved, but we can mitigate this for now, because since OpenSSH 7.5 there is the "accept-new" option to StrictHostKeyChecking, which does exactly what I thought "no" would do: If this flag is set to ``accept-new'' then ssh will automatically add new host keys to the user known hosts files, but will not permit connections to hosts with changed host keys. Signed-off-by: aszlig <[email protected]>
From issue NixOS#696: The hardcoded -o StrictHostKeyChecking=no everywhere is a big SecOps no-no. It's quite feasible an attacker could wind up with an IP address you neglect to change after relinquishing, and have an entire host config hand-delivered to him to inspect for vulnerabilities. He wouldn't be able to MITM the the deployment, but obtaining what is essentially a dump of the host's whole filesystem is still pretty disastrous, from a defensive standpoint. I by myself have been guilty of using this (added this to the Hetzner backend), because I did actually misunderstand the meaning of setting this option to no. My understanding was that it will refuse to connect whenever an existing host key is different from that in known hosts. However, this turns out to be only true for keyboard interactive or password authentication and if we're using pubkey auth, OpenSSH will happily connect. Now the real fix for this (already deploying with a pre-generated host key) is a bit more involved, but we can mitigate this for now, because since OpenSSH 7.5 there is the "accept-new" option to StrictHostKeyChecking, which does exactly what I thought "no" would do: If this flag is set to ``accept-new'' then ssh will automatically add new host keys to the user known hosts files, but will not permit connections to hosts with changed host keys. Signed-off-by: aszlig <[email protected]>
This backend is a stripped down version of "none" backend without key pair generation / loading on the target machine. It instead relies on system/user SSH config for both authentication and host-key checking. This means that appropriate SSH keys needs to be added to targets manually. Related to NixOS#696 and many issues with SSH bootstrapping/recovery.
This backend is a stripped down version of "none" backend without key pair generation / loading on the target machine. It instead relies on system/user SSH config for both authentication and host-key checking. This means that appropriate SSH keys needs to be added to targets manually. Related to NixOS#696 and many issues with SSH bootstrapping/recovery.
We don't use =no anymore. |
The hardcoded
-o StrictHostKeyChecking=no
everywhere is a big SecOps no-no. It's quite feasible an attacker could wind up with an IP address you neglect to change after relinquishing, and have an entire host config hand-delivered to him to inspect for vulnerabilities. He wouldn't be able to MITM the the deployment, but obtaining what is essentially a dump of the host's whole filesystem is still pretty disastrous, from a defensive standpoint.Ideallly, as @oconnorr suggested in #262, nixops would have its own known_hosts mapping cached, but short of that, I'd like to at least have the option of turning on StrictHostKeyChecking=yes permanently somehow. It really should be at least =ask by default, too, but I expect handling the user interaction could cause some grief. I'd much rather have to
ssh-keygen -R $host; ssh $host :
every time a host changes its keys, than compromise a big part of ssh's integrity for a small convenience.The text was updated successfully, but these errors were encountered: