Skip to content
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

Separate incoming and outgoing metadata in context #1157

Merged
merged 2 commits into from
Apr 7, 2017

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Mar 28, 2017

This will prevent the incoming RPCs' metadata from appearing in outgoing RPCs
unless it is explicitly copied, e.g.:

incomingMD, ok := metadata.FromContext(ctx)
if ok {
ctx = metadata.NewContext(ctx, incomingMD)
}

Fixes #1148

@dfawley
Copy link
Member Author

dfawley commented Mar 28, 2017

I would appreciate some advice for how/where to test this change.

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about implementing a "proxy gRPC server" that forwards the requests and responses.
The proxy server will reuse the context to start the forwarding RPC, and the test can check that metadata is not carried over, but other things (like timeout) are carried over.


// NewContext creates a new context with md attached.
// NewContext creates a new context with outgoing md attached.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also have a NewOutgoingContext?
So we can make NewContext call NewOutgoingContext,
and probably guide new users to use the new function instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

This will prevent the incoming RPCs' metadata from appearing in outgoing RPCs
unless it is explicitly copied, e.g.:

incomingMD, ok := metadata.FromContext(ctx)
if ok {
  ctx = metadata.NewContext(ctx, incomingMD)
}

Fixes grpc#1148
@dfawley
Copy link
Member Author

dfawley commented Apr 6, 2017

PTAL, thanks!

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dfawley dfawley merged commit 0c1d39d into grpc:master Apr 7, 2017
@dfawley dfawley deleted the metadata_dont_forward branch April 7, 2017 18:55
@menghanl menghanl added the 1.3 label Apr 8, 2017
@tsuna
Copy link
Contributor

tsuna commented Apr 11, 2017

This change broke backward compatibility, I filed #1178 to track the issue.

@elvizlai
Copy link
Contributor

elvizlai commented May 2, 2017

Wow, this changes broke backward compatibility, especially our trace system.

Every request has a trace-id set to ctx.

For example, service A call B, B call C and then B resp to A.

We do not need handle ctx in v1.2.1.
But now we need to get MD from ctx received in B and put it into a new ctx before we call C.

@dfawley
Copy link
Member Author

dfawley commented May 2, 2017

This is considered a fix for a fairly serious security bug. Automatically forwarding information between services was never intentional. Even so, I am sorry this change caused problems for you, and I apologize for not announcing it more broadly before it was merged. We are working to improve our communication, and we will use this as an example of things we can do better.

@bufdev
Copy link
Contributor

bufdev commented May 4, 2017

I can confirm this is very breaking, I had to hunt down this PR using git blame unfortunately :(

@c4milo
Copy link
Contributor

c4milo commented May 29, 2017

This change also broke my code. Although, I understand it was done because of security concerns.

jml added a commit to weaveworks/common that referenced this pull request Sep 18, 2017
grpc/grpc-go#1157 changed the APIs for getting
metadata from contexts and making contexts from metadata.

This PR updates common to rely on the new library.

Means that anyone who vendors common will need a recent grpc-go too.
jml added a commit to weaveworks/common that referenced this pull request Sep 18, 2017
grpc/grpc-go#1157 changed the APIs for getting
metadata from contexts and making contexts from metadata.

This PR updates common to rely on the new library.

Means that anyone who vendors common will need a recent grpc-go too.
kalilsn pushed a commit to adhocteam/soapbox that referenced this pull request Aug 2, 2018
kalilsn pushed a commit to adhocteam/soapbox that referenced this pull request Aug 3, 2018
* Add API authentication mechanism

* Decode HMAC string correctly

* Make server decide when to auth

* Fix call to removed grpc method (see grpc/grpc-go#1157)

* Fix api_client references

* Add login token to controller spec

* Stop naming our error variables

* Add comment about static auth token

* Fix merge error
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: API Change Breaking API changes (experimental APIs only!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants