fix: Sanitize custom metadata#138
Merged
LucioFranco merged 2 commits intohyperium:masterfrom Nov 15, 2019
Merged
Conversation
LucioFranco
reviewed
Nov 14, 2019
tonic/src/metadata/map.rs
Outdated
| /// | ||
| /// assert!(http_map.get("grpc-timeout").is_none()); | ||
| /// ``` | ||
| pub fn into_sanitized_headers(mut self) -> http::HeaderMap { |
Member
There was a problem hiding this comment.
I think we should probably make this pub(crate) for now? Like we do with into http in request/response.
bdef397 to
19cee99
Compare
rabbitinspace
pushed a commit
to satelit-project/tonic
that referenced
this pull request
Jan 1, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Tonic's
MetadataMapprevents entries with invalid or reserved HTTP2 header names to be inserted but does not disallow headers reserved by the gRPC protocol.The metadata map is then copied verbatim to HTTP headers and written the wire. Some headers may be updated by inserting new values but some will be written as-is.
Solution
This patch prevents a small set of headers to be written when sending requests or responses. It does not panic or returns errors if entries with these names are added to the metadata map, it just won't copy them to http request or responses.