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

rbac: support match based on destination cluster #4455

Open
lizan opened this issue Sep 18, 2018 · 22 comments
Open

rbac: support match based on destination cluster #4455

lizan opened this issue Sep 18, 2018 · 22 comments
Labels
design proposal Needs design doc/proposal before implementation help wanted Needs help!

Comments

@lizan
Copy link
Member

lizan commented Sep 18, 2018

Description:
Envoy can route traffic to clusters based on external given input, e.g. cluster_header in http_conn_manager, and there will be similar proposal for TCP in #4444. We should disallow traffic from listeners going to certain clusters, e.g. xDS API cluster (especially SDS), ratelimit cluster, ext_authz cluster etc.

cc @rshriram

Relevant Links:
#4444 (comment)

@htuch
Copy link
Member

htuch commented Sep 18, 2018

@lizan is the more general way to solve this to provide a list of allowed routable clusters (or blacklist) in the RouteConfiguration? I.e. is this more a policy issue best addressed in the control plane, where you would control beyond "private/internal" marking at the cluster level.

@htuch htuch added design proposal Needs design doc/proposal before implementation help wanted Needs help! labels Sep 18, 2018
@lizan
Copy link
Member Author

lizan commented Sep 18, 2018

The more general way to solve this to provide a list of allowed routable clusters (or blacklist) in the RouteConfiguration?

The general allow/deny list is already achievable with RBAC filter for both TCP and HTTP. Making a cluster private/internal is just an additional way to prevent leaking sensitive information from certain clusters (especially SDS) that you would never want traffic routed to.

@mattklein123
Copy link
Member

In general I would also prefer that we handle this in the RBAC filters. Is that what is being proposed here?

@lizan
Copy link
Member Author

lizan commented Sep 19, 2018

@mattklein123 No, I'm proposing add a flag to cluster level that preventing traffic not generated by Envoy itself being routed to, without relying RBAC to be configured on every listeners/HCM. It is non-trivial to configure every listener/HCM with RBAC correctly to avoid external traffic to a specific cluster.

@mattklein123
Copy link
Member

It is non-trivial to configure every listener/HCM with RBAC correctly to avoid external traffic to a specific cluster.

To play devils advocate, why? This seems like an RBAC problem? Can't we have an RBAC rule to deny traffic that is destined for a particular route? It seems pretty straightforward to me?

In general I would prefer to not add special cases to the router for things like this that IMO should be handled by RBAC?

@lizan
Copy link
Member Author

lizan commented Sep 19, 2018

We don't have a mechanism to enforce RBAC globally across all listeners/HCMs? If there is a way to do that I'm fine with that too.

@mattklein123
Copy link
Member

We don't have a mechanism to enforce RBAC globally across all listeners/HCMs? If there is a way to do that I'm fine with that too.

Install the filter on every listener?

@lizan
Copy link
Member Author

lizan commented Sep 19, 2018

Install the filter on every listener?

Yeah sure it works, but IMO it is too much for just disallowing traffic to a certain clusters. (Note clusters might have credentials configured with it.) In HCM, the RBAC filter comes in front of router, so it need to be configured to match what cluster_header configured in router or delivered by RDS.

It is technically possible to let control planes to figure out all of this and install RBAC filter (perhaps merge existing RBAC rules) accordingly. Though in most cases only certain clusters are private for internal use, there should be a fail-safe flag on cluster side for security in Envoy core, instead of having all logics above to compute RBAC rules. Thoughts?

@mattklein123
Copy link
Member

It is technically possible to let control planes to figure out all of this and install RBAC filter (perhaps merge existing RBAC rules) accordingly. Though in most cases only certain clusters are private for internal use, there should be a fail-safe flag on cluster side for security in Envoy core, instead of having all logics above to compute RBAC rules. Thoughts?

I see your point. Where I am mainly coming from is it's not clear to me that we should have multiple ways of doing something unless it is really necessary. This feels like an RBAC problem that we should solve with the RBAC filter, even if the management server needs to machine generate more config. @envoyproxy/maintainers anyone have any thoughts on this?

@ggreenway
Copy link
Contributor

I tend to agree with @mattklein123. I think my objection is that this change assumes there are only 2 classes of clusters. What if I have 3 classes instead, which are "routable from listener1 via header", "routable from listener2 via header", and "envoy-internal (xDS, etc)"?

@lizan
Copy link
Member Author

lizan commented Sep 20, 2018

@ggreenway this is only for routable or not, more than that should be RBAC.

Another point: this is also the difference between GoogleGrpc and EnvoyGrpc. xDS configured by REST or EnvoyGrpc has the risk that a unintended traffic could be routed to by misconfiguration, while GoogleGrpc is not routable at all.

@rshriram
Copy link
Member

to throw to this mix, consider the case where the cluster name is taken from the SNI value? RBAC gets more complicated here as well.

@htuch
Copy link
Member

htuch commented Sep 20, 2018

My earlier suggestion is really a preference that we put mechanism in Envoy and the policy in the management server. I think the question is how complicated is the implementation of a general whitelist/blacklist? If it's going to be O(100) lines of code, I think its worth making it general, any more complicated and yeah, sure, just a non-routable tag would make sense.

An early API design principle is that the protos are intended to be machine generated, so we can err away from brevity here.

@lizan
Copy link
Member Author

lizan commented Sep 21, 2018

With current implementations, it is tricky for control-planes to generate, especially for cluster_header in HTTP with the filter order (per route config cannot have multiple configs for same filter) and route cache if filters in middle set that header. If we have upstream filter #173 and RBAC there, I agree that the rule would be pretty simple enough to generate so we don't need this flag.

@mattklein123
Copy link
Member

@lizan sorry I still don't understand why this is hard to do with the existing RBAC filter. Can you describe your use case in more detail?

@mattklein123 mattklein123 removed help wanted Needs help! labels Sep 26, 2018
@stale
Copy link

stale bot commented Oct 26, 2018

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Oct 26, 2018
@lizan
Copy link
Member Author

lizan commented Oct 30, 2018

Sorry I didn't have a chance to revisit this. On a second thought, with current RBAC filter we at least need add destination cluster rule to make this easy. With that it will be fairly easy to setup RBAC rules to prevent traffic to certain cluster, without complexing RBAC rules due to route configuration etc.

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Oct 30, 2018
@mattklein123
Copy link
Member

On a second thought, with current RBAC filter we at least need add destination cluster rule to make this easy.

Agreed. This is generally useful. Please add!

@stale
Copy link

stale bot commented Nov 29, 2018

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Nov 29, 2018
@lizan lizan changed the title cds: ability to make a cluster private or internal rbac: support match based on destination cluster Nov 30, 2018
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Nov 30, 2018
@lizan lizan added help wanted Needs help! stale stalebot believes this issue/PR has not been touched recently labels Nov 30, 2018
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Nov 30, 2018
@yangminzhu
Copy link
Contributor

@lizan
Is the rule to be added to the RBAC policy just a string of the cluster name?

@lizan
Copy link
Member Author

lizan commented Apr 10, 2019

@yangminzhu yeah adding a rule to RBAC policy would be good.

@rwaweber
Copy link

Hey all, sorry to dust off an old issue!
I could be wrong, but it doesn't look like this made it into the rbac filter. Given its been a few years, this very well may not be the best place to put this anymore, but I would love to be able to use this feature to be able to leverage the rich RBAC logic to pass a request directly to a destination cluster. Happy to help if I can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design proposal Needs design doc/proposal before implementation help wanted Needs help!
Projects
None yet
Development

No branches or pull requests

7 participants