Bug 3016 - (still) not generating correct RSA SHA2 signatures from certificate files loaded in ssh-agent
Summary: (still) not generating correct RSA SHA2 signatures from certificate files loa...
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh-agent (show other bugs)
Version: 8.0p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_8_1
  Show dependency treegraph
 
Reported: 2019-05-29 23:55 AEST by Jakub Jelen
Modified: 2021-04-23 14:55 AEST (History)
2 users (show)

See Also:


Attachments
use correct algorithm identification in ssh-agent (780 bytes, text/plain)
2019-05-29 23:55 AEST, Jakub Jelen
dtucker: ok+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelen 2019-05-29 23:55:21 AEST
Created attachment 3288 [details]
use correct algorithm identification in ssh-agent

If I read the certkeys specification [1] and the source code correctly, the ssh-agent does not generate correct signatures when the certificate is loaded in agent.

The agent_decode_alg() function [2] looks only on the actual key type and for certificate key types, does not generate correct alg argument for the sshkey_sign() function (ending with raw ssh-rsa signature).

This is not the same what happens in sshconnect2.c in key_sig_algorithm() [3], where also the certificate types are taken into the account and the alg argument to sshkey_sign() is properly formatted.

I do not have separate reproducer inside of OpenSSH since I was using OpenSSH agent, libssh client and openSSH server, which failed to verify these signatures (when the base rsa-ssh algorithms were disabled).

The attached patch resolved the issue for me in the above setup. I am not sure whether there is some more elegant way how to achieve the same.

[1] https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys#L41
[2] https://github.com/openssh/openssh-portable/blob/master/ssh-agent.c#L265
[3] https://github.com/openssh/openssh-portable/blob/master/sshconnect2.c#L1102
Comment 1 Damien Miller 2019-05-31 13:27:54 AEST
Looks correct (sigh); I'll get it committed
Comment 2 Damien Miller 2019-06-14 13:53:44 AEST
Committed in 2317ce4b0ed7d and will be available in OpenSSH 8.1. I'll also cherry-pick this to the V_8_0 stable branch.
Comment 3 Damien Miller 2021-04-23 14:55:40 AEST
closing resolved bugs as of 8.6p1 release