-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Panic on non-utf-8 status messaage #2078
Comments
Can you also provide the message you are trying to return in both cases? A code snippet to create the status in both cases would also be helpful.
IIUC, encoded messages should all be ASCII. It's not clear to me how this will result in violation of http2 protocol. An example would help here. |
I've used Here is a panic stack trace caused by non-utf-8 message:
gRPC HTTP2 protocol is a bit more precise:
But grpc-go doesn't perform any validation of message returned by application handler and therefore sends ASCII encoded string followed by percent encoding which is not always a valid UTF-8 string. |
I see. There are two problems here:
For problem 1, we could add a check for user input, and strip invalid utf-8 chars (by replacing them with Unicode replacement character). The same approach should happen on the receiving side, too. Problem 2 won't be a problem in the invalid utf-8 cases after we solve problem 1. |
fixes #2078 A status with invalid utf-8 characters could still be created, but invalid characters will be replaced with [Unicode replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) before being sent out. Those bytes will still be percent encoded. All details added to this invalid status will be dropped.
fix reverted in #2127 |
fixes grpc#2078 A status with invalid utf-8 characters could still be created, but invalid characters will be replaced with [Unicode replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) before being sent out. Those bytes will still be percent encoded. All details added to this invalid status will be dropped.
fixes #2078 A status with invalid utf-8 characters could still be created, but invalid characters will be replaced with [Unicode replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) before being sent out. Those bytes will still be percent encoded. All details added to this invalid status will be dropped.
Please answer these questions before submitting your issue.
What version of gRPC are you using?
grpc-go 1.11
What version of Go are you using (
go version
)?go version go1.8.4 linux/amd64
What operating system (Linux, Windows, …) and version?
Linux
What did you do?
Server returns status with message which is invalid utf-8 sequence first without details and after that with some details.
What did you expect to see?
Consistent behavior, for example sanitizing message to ensure that it's valid utf-8.
What did you see instead?
Returning status with non-utf-8 message but without details is silently encoded by server and is sent to client. Resulting
status-message
http2 field is not valid escaped utf-8 sequence in violation of http2 protocol spec for grpc.Returning status with non-utf-8 message and with at least one detail causes panic on a server.
The text was updated successfully, but these errors were encountered: