Skip to content
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

Partially mitigate StrictHostKeyChecking=no issue #1023

Merged
merged 1 commit into from Oct 24, 2018

Conversation

aszlig
Copy link
Member

@aszlig aszlig commented Oct 20, 2018

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.

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 <aszlig@nix.build>
@aszlig
Copy link
Member Author

aszlig commented Oct 20, 2018

@edolstra, @rbvermaa: Is there a case where we need to rely on OpenSSH outside of nixpkgs?

@kampka
Copy link

kampka commented Oct 22, 2018

I am much happier with this than with the original behavior.
Since this is still not a partial fix, I think it would be a good idea to add some documentation that this is happening and add a quick warning / howto for security conscious users.
At least no one is going to be surprised about it then.

@edolstra
Copy link
Member

@aszlig No, don't think so.

@edolstra edolstra merged commit abef2ed into master Oct 24, 2018
@grahamc grahamc deleted the strict-hostkey-checking-workaround branch May 7, 2020 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants