Skip to content

Conversation

@Lukasa
Copy link
Contributor

@Lukasa Lukasa commented May 29, 2020

Motivation:

We took a shortcut in our code for negotiating which host key algorithm
to use, which is that we preferred the first one in our list that was
also in the peer's. This is obviously not right: the preference is
supposed to be the first one in the client's that's also in the
server's. We just happened to be unlucky enough to get away with this
for now.

While I was investigating this I also spotted that we never actually
validated that the server respected the negotiation result, so that code
had to be added too.

Modifications:

  • Updated the negotiation code to validate that the server sends back a
    key of the right type.
  • Updated the negotiation code to ensure that we negotiate host keys per
    the spec.

Result:

We negotiate host keys the way we're supposed to.

Motivation:

We took a shortcut in our code for negotiating which host key algorithm
to use, which is that we preferred the first one in our list that was
also in the peer's. This is obviously not right: the preference is
supposed to be the first one in the client's that's also in the
server's. We just happened to be unlucky enough to get away with this
for now.

While I was investigating this I also spotted that we never actually
validated that the server respected the negotiation result, so that code
had to be added too.

Modifications:

- Updated the negotiation code to validate that the server sends back a
  key of the right type.
- Updated the negotiation code to ensure that we negotiate host keys per
  the spec.

Result:

We negotiate host keys the way we're supposed to.
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label May 29, 2020
@Lukasa Lukasa requested review from Joannis, artemredkin and weissi May 29, 2020 13:47
@Lukasa Lukasa added 🆕 semver/minor Adds new public API. and removed 🔨 semver/patch No public API change. labels May 29, 2020
Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Copy link
Contributor

@Joannis Joannis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an interesting oversight, and it's even more interesting that this never resulted in a failed connection. Good catch!

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM

@Lukasa Lukasa merged commit 75c6db3 into apple:master Jun 1, 2020
@Lukasa Lukasa deleted the cb-host-key-negotiation branch June 1, 2020 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants