-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: add a specific error for algorithm negotiation issues/errors #61536
Comments
This sounds good. Two notes: it should be possible to make this play well with #58523, at least to expose the remote’s supported algorithms, which might be useful to track in metrics for applications; and we can make the final error string the same as before so we don’t break current string matching applications.ErrAlgorithms feels a bit generic as a name. ErrAlgorithmNegotiation or ErrNoCommonAlgorithms?
|
@FiloSottile do you mean something like this?
so we can use
|
I mean that if in #58523 we come up with an Algorithms type, we should maybe expose it as part of AlgorithmNegotiationError. (No need to have ErrAlgorithmNegotiation if we have AlgorithmNegotiationError, applications can just use errors.As.) |
ok thanks. So the struct approach should be fine
for now the algorithms are strings. If this changes in the future, we can use of the Algorithm type instead of strings. However, it's probably better to wait for an accepted proposal for #58523 before proceeding here |
we can't change the type for things like "aes128-ctr" from string to something else. That would break backward compatibility. |
This proposal has been added to the active column of the proposals project |
not sure: that bug is about exposing algorithms in a successful connection setup (single algorithm for hostkey, kex, mac & cipher), where this issue is about unsuccessful connection setup (list of algorithms for one of {kex,mac,cipher,hostkey}). For backward compat reasons, the algorithms have to be string, so I don't think you can do much better than a proposal of |
@hanwen if we want to add Other than that, what do you think about this?
|
I don't understand what the inner error is good for. other than that, Requested+Supported is likely needed to make sure the error string doesn't change, so LGTM. |
the inner error is to encapsulate the current error and thus keep the same error string for people who, copying our test cases, do things like An example of usage in
|
@drakkan I still don't see why you need |
This error can also be used in other places than |
I agree with Russ that the inner error seems out of place. Can we change the details of how the error string is formatted, or is that subject to a compat promise too? If we want to keep the string completely intact, it's a little annoying, because it says "server" and "client", so we'd have to add an IsServer or IsClient boolean. re. other places: worst case, we can introduce different error types for the different types of negotiation failures. |
I'm not sure about the compat promise for error strings, maybe there is no compat promise here.
yes, this is the point, if we can change the error string it would be simpler. In our test case we do this. I also do something similar in SFTPGo because an algorithm negotiation error must be reported differently from other errors. Maybe we could just leave
we can but even there we have a list of supported algos and a list of requested algos so this error would fit perfectly |
No new comments here since August. Have we converged on an API proposal? |
Any updates here? |
Sorry for the delay. I think we can simplify the proposal like this
we will discuss the structure's private fields and other implementation details in the CL. I think it's reasonable to use this error only for client/server negotiation errors and not other places too and we can keep the current error string to avoid any issues to our users |
Have all remaining concerns about this proposal been addressed? Proposal is to add:
|
Based on the discussion above, this proposal seems like a likely accept. Proposal is to add:
|
Change https://go.dev/cl/559056 mentions this issue: |
No change in consensus, so accepted. 🎉 Proposal is to add:
|
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
Fixes golang/go#61536 Change-Id: Id38cc6d46879dbe2bdea04dec061596387ec6cfe
A common requirement for applications using x/crypto/ssh is to report some errors differently than others.
We currently have
ServerAuthError
andErrNoAuth
which are useful for authentication related errors.If the client and the server cannot negotiate a common algorithm for host key, KEX, cipher, MAC we have a generic error and can only search for the error string.
New algorithms are added over time and old algorithms are deprecated and disabled by default, so a well defined error allows applications using the library to better report errors to end users and allow them to fix the issue (e.g by enabling an old algorithm).
An algorithm negotiation error is typically returned in the findCommon method, but the same error should also be returned in other places, for example if pickHostKey fails or in enterKeyExchange so searching for an error string is quite fragile.
We can add something very simple like this
and wrap this error when needed, for example in
findCommon
we could useinstead of
and the same in other places where there is an algorithm error.
If you see CL 508398, this error may also be returned if
NewSignerWithAlgorithms
fails for example.We could also evaluate something more complex, such as an error structure with an exported error code for each error category.
This way we could, for example, have specific error codes for MAC, KEX or cipher negotiation errors, I'm not sure if it's worth the effort to implement and maintain, but if you prefer this approach I can try to propose an API for that as well.
cc @golang/security
The text was updated successfully, but these errors were encountered: