-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ssh: relax RSA signature check in SSH_MSG_USERAUTH_REQUEST #221
Conversation
8bf4ccc
to
443b8cb
Compare
This PR (HEAD: 443b8cb) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/crypto/+/412854 to see it. Tip: You can toggle comments from me using the |
Message from Maxime Tremblay: Patch Set 1: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Hi, thanks for working on this. I planned to take a look this weekend. Maybe something like the following (untested) is a bit more generic and will potentially work for other algos in the future
|
Based on golang#221 This PR also relaxes the check for SSH certificates. Older OpenSSH clients versions (7.4 included in CentOS 7 for example) that don't understand `rsa-sha2-256-cert-v01@openssh.com` or `rsa-sha2-512-cert-v01@openssh.com` send SSH certificates signed SHA2 and the public key type set to `ssh-rsa-cert-v01@openssh.com`. Currently, this combination is rejected by `go/crypto`. OpenSSH implemented their own workaround for the problem https://github.com/openssh/openssh-portable/blob/25c8a2bbcc10c493d27faea57c42a6bf13fa51f2/ssh-rsa.c#L505-L518 openssh/openssh-portable@4ba0d54
443b8cb
to
08edff8
Compare
This PR (HEAD: 08edff8) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/crypto/+/412854 to see it. Tip: You can toggle comments from me using the |
Message from Jakub Nyckowski: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
08edff8
to
630f719
Compare
This PR (HEAD: 630f719) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/crypto/+/412854 to see it. Tip: You can toggle comments from me using the |
Message from Maxime Tremblay: Patch Set 3: Code-Review+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
@FiloSottile Is there anything I can do to get this change merged? |
Message from Stan Hu: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 3: Code-Review+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Roland Shoemaker: Patch Set 3: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Gopher Robot: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Gopher Robot: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Roland Shoemaker: Patch Set 4: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Gopher Robot: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Gopher Robot: Patch Set 4: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Jakub Nyckowski: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 4: Code-Review+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Jakub Nyckowski: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Jakub Nyckowski: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Nicola Murino: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Jakub Nyckowski: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Buggy SSH clients, such as gpg-agent v2.2.4 and OpenSSH v7.6 shipped in Ubuntu 18.04, may send `ssh-rsa-512` as the public key algorithm but actually include an `rsa-sha` signature. If RFC 3808 (extension negotiation) is implemented, these clients will fail to authenticate with the error: ``` ssh: signature "ssh-rsa" came in for selected algorithm "rsa-sha2-512", public key is type ssh-rsa ``` According to RFC 8332 section 3.2: If the client includes the signature field, the client MUST encode the same algorithm name in the signature as in SSH_MSG_USERAUTH_REQUEST -- either "rsa-sha2-256" or "rsa-sha2-512". If a server receives a mismatching request, it MAY apply arbitrary authentication penalties, including but not limited to authentication failure or disconnect. ...A server MAY, but is not required to, accept this variant or another variant that corresponds to a good-faith implementation and is considered safe to accept. While the client is expected to do the right thing, in practice older clients may not fully support `ssh-rsa-256` and `ssh-rsa-512`. For example, gpg-agent v2.2.6 added support for these newer signature types. To accomodate these clients, relax the matching constraint: if the `SSH_MSG_USERAUTH_REQUEST` message specifies an RSA public key algorithm and includes an RSA public key, then allow any of the following signature types: - `rsa-sha-512` - `rsa-sha-256` - `rsa-sha` This emulates what OpenSSH does. OpenSSH only considers that the RSA family is specified and then verifies if the signature and public key match. Closes golang/go#53391
Message from Stan Hu: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
630f719
to
9c9ba6a
Compare
This PR (HEAD: 9c9ba6a) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/crypto/+/412854 to see it. Tip: You can toggle comments from me using the |
Message from Nicola Murino: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Nicola Murino: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 5: Code-Review+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Ash McKenzie: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from David Chase: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from tricium-prod@appspot.gserviceaccount.com: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Nicola Murino: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Message from Stan Hu: Patch Set 5: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/412854. |
Closing in favor of #261. |
Will reopen to see whether #261 is preferable. |
This PR is being closed because golang.org/cl/412854 has been abandoned. GitHub PR #221 has been closed. |
Buggy SSH clients, such as gpg-agent v2.2.4 and OpenSSH v7.6 shipped
in Ubuntu 18.04, may send
ssh-rsa-512
as the public key algorithmbut actually include an
rsa-sha
signature.If RFC 3808 (extension negotiation) is implemented, these clients will
fail to authenticate with the error:
According to RFC 8332 section 3.2:
If the client includes the signature field, the client MUST encode the
same algorithm name in the signature as in SSH_MSG_USERAUTH_REQUEST --
either "rsa-sha2-256" or "rsa-sha2-512". If a server receives a
mismatching request, it MAY apply arbitrary authentication penalties,
including but not limited to authentication failure or disconnect.
...A server MAY, but is not required to, accept this variant or another
variant that corresponds to a good-faith implementation and is
considered safe to accept.
While the client is expected to do the right thing, in practice older
clients may not fully support
ssh-rsa-256
andssh-rsa-512
. Forexample, gpg-agent v2.2.6 added support for these newer signature
types.
To accomodate these clients, relax the matching constraint: if the
SSH_MSG_USERAUTH_REQUEST
message specifies an RSA public keyalgorithm and includes an RSA public key, then allow any of the
following signature types:
rsa-sha-512
rsa-sha-256
rsa-sha
This emulates what OpenSSH does. OpenSSH only considers that the RSA
family is specified and then verifies if the signature and public key
match.
Closes golang/go#53391