-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/crypto/ssh: allow unpadded signatures #68286
Comments
Sample white-space-damaged patch which fixes it (although I'm not 100% sure if rsaPublicKey::Verify is ever called in cases where the short signature should not be accepted:
|
@drakkan @golang/security per owners |
Note the PuTTY commit here: https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=a5bcf3d384e1bf15a51a6923c3724cbbee022d8e They will continue to send unpadded signatures for ssh-rsa, but will provided padded versions for rsa-sha2-*. |
Hi @imirkin I think we should pad only |
Hi @drakkan, You could be compliant with the specs and allow the short signatures on
And this would allow I'd strongly encourage allowing the short signatures for all RSA variants. |
@imirkin In general I think it is better to keep legacy code to a minimum. Putty will be updated over time and also ssh-rsa support will be removed in the future, so we may get rid of this code in the future. At the same time it needs to be added now because we are not compliant with the spec |
@drakkan So what about everyone who has to support actual users? Create & maintain a private copy of x/crypto/ssh for a decade until the version of Windows runs out of support and people are forced to think about upgrades? The SSH library has various allowances for how OpenSSH clients actually work, various oddities around picking ssh-rsa vs rsa-sha2 algos/allowing "wrong" values, in order to work with actual software. Why not let it work with PuTTY and other Windows clients that embed it? And I'll point out again that allowing short signatures is actually allowed (but not required) by the spec. |
@imirkin I understand that you have a problem now and want to fix it in one place without requiring your clients to update anything and we will take that into account. It is unlikely that putty will not have a security bug for the next 10 years so the various clients should be updated sooner or later and ssh-rsa signature format is already deprecated and will be removed in the future. If you want to submit a CL we can also discuss about this during the review. Thanks |
FWIW, it's not just PuTTY and its embeddors. SSH.NET had a similar bug (very recently fixed) too: [To give full credit: this bug, which was already closed by the time I saw it is what led me to understand what I was seeing with some of my users.] I'll try to put a patch together this week for x/crypto/ssh with a test. |
Change https://go.dev/cl/598534 mentions this issue: |
Go version
go version go1.20.13 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Connect a lot of times to the SSH server with an RSA public key using PuTTY.
What did you see happen?
Occasional login failures with
crypto/rsa: verification error
What did you expect to see?
All successes.
The issue is due to a short signature, rejected by
rsa.VerifyPKCS1v15
.https://datatracker.ietf.org/doc/html/rfc4253#section-6.6
Which requires the signature to be unpadded.
I spoke with the PuTTY maintainer about this, Simon Tatham. His view is that the SSH RFC supercedes the PKCS RFC (8017), so the short signature is OK (in fact required).
However this approach is reversed in
https://datatracker.ietf.org/doc/html/rfc8332#section-3
and I believe that PuTTY may be fixed for this when using the new signature types (or even always). But even if it is, lots of PuTTY installs out there that will not be updated for a long time. (And WinSCP embeds PuTTY, thus has a similar issue... FileZilla as well potentially.)
In practice, the OpenSSH verify logic always allows unpadded signatures, while the sign logic always pads them (at least based on a quick read of https://github.com/openssh/openssh-portable/blob/master/ssh-rsa.c ssh_rsa_sign and ssh_rsa_verify). The current Go implementation is out of spec for
ssh-rsa
signatures, but it would be the flexible thing to do to also always allow the short signatures, as this is allowed by the RFC and (arguably) the most popular SSH server.I'm happy to write up a patch if there are any prospects of it being accepted (past experience suggests this is best left to the core team though).
The text was updated successfully, but these errors were encountered: