-
Notifications
You must be signed in to change notification settings - Fork 108
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
Modifying errors that occur before interceptors #584
Comments
@anzboi, we are looking into this and exploring options in the connect-go runtime. |
I've audited all of the kinds of errors that can happen before the interceptor or handler is called. There are three errors that do not result in any RPC error written to the output, because they are protocol errors -- the server can't even determine what protocol the client is using, so it doesn't know what format to use for errors. So it just writes an HTTP code, sets some HTTP response headers, and leaves the response body empty:
Then there are other errors that can prevent dispatch of the RPC. So the protocol is known, but something else about the request cannot be handled by the server. The table below enumerates them all.
* Only applies to Connect unary protocol when using GET HTTP method. @anzboi, so I think the only case that potentially leaks information is the one you describe -- the last entry in the table, where the request message for a unary RPC cannot be deserialized. In this case, most of the error comes from the So a very targeted solution to this one class of errors is to fix the framework so that all of the error message comes from the How does that sound as a very pinpointed work-around? |
@jhump I do worry about the robustness of this work-around in the long term. While this table is great to see, it can change over time, very easy to accidentally introduce a new error that occurs in some cases. It also feels like an odd way to handle an issue like this.
|
@anzboi What error message would you expect here? We designed under the assumption that the schema for the API is available to all clients of the API (as is typical for Protobuf), so to my eye the error message isn't leaking anything that the client doesn't already have access to. |
Something generic. This particular error case was flagged as low risk internally so keep in mind this is not really a big deal. Knowing the full set of possible errors alleviates this somewhat so personally I'm happy without a fix (or simply implementing a custom Codec). Maybe our security partner @danh-ng can provide more details. |
FWIW, a proper solution could still be implemented in the future. But at the moment, a good solution is not clear, and any solution would almost certainly increase exported API surface area that we must remain compatible with until a v2 (or forever). So we're being cautious in what we change and add, so that we don't get stuck supporting a "smelly band-aid" that could make better solutions harder to implement in the future. Actually winding these calls through an interceptor, particularly a unary interceptor, is problematic because the signature of the interceptor functions doesn't provide anyway for the framework to indicate that the RPC has already failed. The unary interceptor is the most problematic because it receives a deserialized request message, which cannot actually be provided under the above error scenarios. One possible thought is to provide a So implementing a custom |
This is so that a custom `Codec` can choose what details to reveal to clients, in cases where emitting the destination message type is considered to leak too much information. See #584 for more context.
The error in question is now fully controlled by the Codec implementation. To customize it, users can now replace the protobuf and/or protojson codec. This will go out with the next release. |
Is your feature request related to a problem? Please describe.
Our security team flagged a low risk issue that is probably worth addressing anyway. Errors that occur before a request reaches interceptors/endpoint are not masked with a generic error response.
Describe the solution you'd like
In general it is good practice to catch any unhandled errors and provide some kind of generic response to clients. Connect currently has no generic error handler for errors that occur before request handling reaches the interceptors or endpoint. In particular, we would like the following
Describe alternatives you've considered
Since this occurs before control is handed to anything we have control over, the only other option is to implement a custom
http.ResponseWriter
that somehow detects when the error response is created before handling reaches interceptors/endpoints. This is not a trivial task.Additional context
Example test case. This produces a response showing some internal service details is being returned to a client (a client might guess the service is written in go). It is also worth noting there is no way to log this error on the server side AFAICT.
Resulting output
The text was updated successfully, but these errors were encountered: