-
Notifications
You must be signed in to change notification settings - Fork 453
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
Permissions and PublicKey passing cleanup #243
base: master
Are you sure you want to change the base?
Conversation
f2f61f2
to
051927a
Compare
051927a
to
c9ca86c
Compare
I think maybe it needs one more check: before calling |
The The reason is that it only reads the "permission in current context", which change a lot. It might not match the ssh connection permission in the session handler. The ideal design should be exposing ssh connection's Permissions directly. |
I agree with your comment on |
@wxiaoguang Could you clarify what you mean by this? I don't think it's accurate. With the fix from x/crypto, the PublicKeyHandler will be called an additional time if the last submitted key doesn't match the one they're actually using, which should resolve the issue. |
I was thinking about this case: if the PasswordHandler does some remote network access to get the public key,
Then what would happen? (Maybe it is not a problem if the last |
In that instance, the last public key handler would cause the auth to fail. Auth doesn't succeed until the user can actually prove they own that public key, by signing some information about the connection with the corresponding private key (See RFC4252, Section 7). If I'm understanding right, as long as x/crypto/ssh was used correctly, previous versions wouldn't have been vulnerable either - the only thing they changed is to make the number of cached permissions responses be 1 rather than 16, having the effect that the last time the PublicKeyHandler called, the actual key used for auth is included. The relevant code is here: https://github.com/golang/crypto/blob/v0.31.0/ssh/server.go#L628-L704. It essentially does the following:
Because of that I don't think we need to additionally make sure the public key is verified before calling the server handler. At the point where the server handler is called, it has already been verified. |
Hey @belak ! Thanks for your work on this. Any idea when this might make it into a new release? We'd love to pick up these changes. |
I was swamped with some work stuff, and really needed a break. I'd be happy to merge this, but I'm a bit unsure if it would break any applications, and as it's a behavior change rather than an API change, I'm a bit worried it would have negative effects people wouldn't be able to easily find, especially since I've seen applications which rely on this broken behavior in the past. Longer term, I'd love to give this package a larger re-write, but I'm not sure when or if I'll have the time, especially given how I don't get to use this package for my day job. |
This makes two modifications:
Because this is a behavior change (even if it's only a change when used incorrectly), this counts as a breaking change and will involve a minor version bump.