openssh-portable icon indicating copy to clipboard operation
openssh-portable copied to clipboard

Don't propose disallowed algorithms during hostkey negotiation

Open ZoltanFridrich opened this issue 3 years ago • 2 comments

I would like to propose a patch from rhel-9.1.0

Context: In rhel-9.1.0 when I try to connect to host that only presents ssh-rsa host keys, the connection fails with a very cryptic error message: ssh_dispatch_run_fatal: Connection to 10.19.208.80 port 22: error in libcrypto I believe this happens because ssh-rsa is disallowed by crypto-policies but openssh disregards the configuration when negotiating hostkey algorithm. Therefore the ssh-rsa hostkey alg is negotiated and the connection fails when openssl returns an error somewhere inside sshkey_verify function.

This patch restricts the range of negotiated algorithms to only those that are allowed by the configuration. Effectively making the connection fail during hostkey negotiation and with a much more descriptive error message.

Signed-off-by: Zoltan Fridrich [email protected]

ZoltanFridrich avatar Jun 10 '22 10:06 ZoltanFridrich

@djmdjm @daztucker Hi, can you please review this MR? I would like to know your opinion on this.

Also, I believe there still remained one memory leak. Afaik order_hostkeyalgs() returns allocated memory which is never freed.

ZoltanFridrich avatar Jul 11 '22 09:07 ZoltanFridrich

The test failures seem expected judging by the output. Basically the negotiation fails because ssh-rsa is not accepted_algo

ZoltanFridrich avatar Jul 12 '22 11:07 ZoltanFridrich

I added a comment on the change, but this isn't correct. We already have HostkeyAlgorithms to control which signature algorithms are used for hostkey negotiation. Your patch instead adds filtering by PubkeyAcceptedAlgorithms, which is used for user authentication.

Please just use HostkeyAlgorithms for what you're trying to achieve.

djmdjm avatar Sep 09 '22 03:09 djmdjm