Bug 3254 - Issue on sshd finds correct private key for a certificate when using ssh-agent
Summary: Issue on sshd finds correct private key for a certificate when using ssh-agent
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 8.4p1
Hardware: Other Linux
: P5 normal
Assignee: Damien Miller
URL:
Keywords:
Depends on:
Blocks: V_8_7
  Show dependency treegraph
 
Reported: 2021-01-23 05:08 AEDT by Miles Zhou
Modified: 2022-02-25 13:59 AEDT (History)
2 users (show)

See Also:


Attachments
check certificate against host public keys (402 bytes, patch)
2021-06-04 13:26 AEST, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Miles Zhou 2021-01-23 05:08:54 AEDT
Please take a look at line 1936 in main() function in sshd.c. 

/* Find matching private key */
	for (j = 0; j < options.num_host_key_files; j++) {
		if (sshkey_equal_public(key,
			sensitive_data.host_keys[j])) {
			sensitive_data.host_certificates[j] = key;
				break;
			}
	}

the sshkey_equal_public() is trying to compare a cert's pub with a private key, and it never find a match which makes sshd cannot use this certificate even though its private key is in ssh-agent.
I believe it should be comparing a cert's public key with a public key in sensitive_data as follow.

/* Find matching private key */
	for (j = 0; j < options.num_host_key_files; j++) {
		if (sshkey_equal_public(key,
			sensitive_data.host_pubkeys[j])) {
			sensitive_data.host_certificates[j] = key;
				break;
			}
	}

https://github.com/openssh/openssh-portable/blob/V_8_4/sshd.c#L1936
Comment 1 Damien Miller 2021-06-04 13:26:09 AEST
Created attachment 3526 [details]
check certificate against host public keys
Comment 2 Damien Miller 2021-06-06 21:35:51 AEST
Thanks - this has been committed as 530739d4 and will be in the next OpenSSH release
Comment 3 Damien Miller 2022-02-25 13:59:06 AEDT
closing bugs resolved before openssh-8.9