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

Gateway API: Guide for removing ClusterRole privileges (Remove unnecessary permissions / ... could lead to takeover of the cluster) #6830

Open
erikschul opened this issue Jan 7, 2025 · 4 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor.

Comments

@erikschul
Copy link

erikschul commented Jan 7, 2025

Please describe the problem you have

I'd like to use Contour with Gateway API, and unfortunately the suggested installation method contains a ClusterRole with full read privileges to all secrets/configmaps, as well as creating deployments.

Since Envoy is publicly exposed, a vulnerability might be used to attack the cluster (although it'd have to jump to the Contour control plane first), as discussed before:

Would it be possible for ProjectContour to explicitly support an installation method with reduced privileges?
I'm concerned about overriding these roles and having instability in production because it deviates from the recommended defaults.

Specifically, I'd be happy with:

  • installing Gateway Provisioner into projectcontour namespace
  • creating all Gateway (Contour/Envoy) instances in that same namespace
  • creating all Certificate (TLS secrets) in the same namespace
  • watching Gateway API resources (routes) globally (minimal ClusterRole)

Wouldn't this remove all the concerning privileges?

  • creating deployments/daemonsets (pods)
  • getting secrets

I think this would also work when using HTTPProxy with includes from the namespace, which I think is already a best practice for a cluster operator to avoid access to the certificates from workload namespaces?

@erikschul erikschul added kind/feature Categorizes issue or PR as related to a new feature. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor. labels Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

Hey @erikschul! Thanks for opening your first issue. We appreciate your contribution and welcome you to our community! We are glad to have you here and to have your input on Contour. You can also join us on our mailing list and in our channel in the Kubernetes Slack Workspace

@erikschul
Copy link
Author

@tsaarni

@tsaarni
Copy link
Member

tsaarni commented Jan 8, 2025

I'm not entirely sure, but I believe it would require changes in how the controller-runtime informers are used to watch updates for different resource types. This complexity comes from the way the Kubernetes REST API works, having one endpoint to watch globally for a resource type, and multiple endpoints for namespace-specific watches. Currently, we support configuring the client to watch all relevant resource types in multiple/specific namespaces using --watch-namespaces=<ns,ns> option, as I also mentioned in the issue you referenced, or in all namespaces. The provisioner also supports this via the ContourDeployment.spec.contour.watchNamespaces parameter.

In the scenario you described, there are two types of watches at the same time e.g. a global watch for Gateway API resource types and namespaced watch for Secrets. I doubt it would be possible to achieve this just by modifying the RBAC rules, I think it requires a code change.

@erikschul
Copy link
Author

Thanks @tsaarni .
In that case, the feature request is more specifically:

  • modify the (contour?) code so that it will search for Gateway API resources in all namespaces (when not using --watch-namespaces), but only search for secrets in other namespaces than projectcontour when necessary (e.g. if an HTTPProxy explicitly requires it, in which case its up to the namespace to provide relevant RoleBindings).

I consider it relatively low risk, but perhaps also in the context of migrating to Gateway API, it would be interesting to support this privilege-limited use case, for example with a 6 month timeframe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor.
Projects
None yet
Development

No branches or pull requests

2 participants