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

[che-auth] secure workspace services #20190

Closed
Tracked by #19182 ...
sparkoo opened this issue Jul 23, 2021 · 5 comments
Closed
Tracked by #19182 ...

[che-auth] secure workspace services #20190

sparkoo opened this issue Jul 23, 2021 · 5 comments
Assignees
Labels
area/che-server kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system.

Comments

@sparkoo
Copy link
Member

sparkoo commented Jul 23, 2021

Is your task related to a problem? Please describe.

With new authentication, we need 2 levels of workspace protection. 1st is in the auth gateway (#19707), that will prevent unauthorized access from outside of the cluster through the ingress/route. 2nd level must be in workspace service, to prevent in-cluster attackers that could potentially access workspace service directly. This issue is about the latter case.

Describe the solution you'd like

I can think of 2 designs:

kube-rbac-proxy per workspace port

  • put kube-rbac-proxy container in front of each opened workspace port and set proper RBAC rules
    krp_port

This should work and we did POC of this solution at #19297.

Big disadvantage of this solution is high overhead as we would need one extra container per open port, because kube-rbac-proxy can have only one upstream.

reverse proxy + kube-rbac-proxy per workspace

rpxy

We did not tested this solution. It has better and constant footprint (+2 containers per workspace), but more complex setup.

Describe alternatives you've considered

  • We could prepare some custom solution, something like kube-rbac-proxy that can do the routing to multiple upstreams by port.
  • We could not care about in-cluster attacks. While this might be ok for onprem installations, it is not ok for SAAS, where anyone from the internet can access.

Additional context

epic: #19182

@sparkoo sparkoo added the kind/task Internal things, technical debt, and to-do tasks to be performed. label Jul 23, 2021
@sparkoo sparkoo changed the title [che-auth] secure workspace services [che-auth] secure workspace services Jul 23, 2021
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Jul 23, 2021
@skabashnyuk
Copy link
Contributor

My two cents.

2nd level must be in workspace service, to prevent in-cluster attackers that could potentially access workspace service directly.

Is this SAAS only problem? Can we say that we trust all users by default and if not we will have to enable some "optional heavy" thing?

Big disadvantage of this solution is high overhead as we would need one extra container per open port, because kube-rbac-proxy can have only one upstream.

Can/should we explore the opportunity to improve this by contributing to kube-rbac-proxy?

CC @l0rd @benoitf

@benoitf
Copy link
Contributor

benoitf commented Jul 26, 2021

yes exploring multiple stream might be better (more upstream solution than a custom one)

about the in-cluster attack, it could be interesting to be have a flag to toggle this

@sleshchenko sleshchenko added severity/P1 Has a major impact to usage or development of the system. area/che-server and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Jul 26, 2021
@sparkoo sparkoo self-assigned this Aug 26, 2021
@sparkoo
Copy link
Member Author

sparkoo commented Aug 31, 2021

While contributing with multiple streams to kube-rbac-proxy may be an option brancz/kube-rbac-proxy#142, there is another issue. Kube-rbac-proxy needs cluster permissions to perform auth check https://github.com/brancz/kube-rbac-proxy/blob/master/examples/resource-attributes/deployment.yaml#L19. That would mean that the every workspace ServiceAccount would need ClusterRoleBinding to this ClusterRole. With devworkspaces, new SA is created for each workspace, so that would mean ClusterRoleBinding per workspace.
Currently creating ServiceAccount and everything related to it is in control of DevWorkspace controller, without any mechanism how to include ClusterRoleBinding to it.

So we have 2 issues with kube-rbac-proxy:

  • multiple streams
  • cluster permissions

Because of time-consuming possible contribution to kube-rbac-proxy upstream + needed downport to openshift port https://github.com/openshift/kube-rbac-proxy and new mechanism of assigning ClusterRoles to workspace ServiceAccount, I think custom solution is cleaner and simpler at this moment. I've put together simple multi-stream auth proxy that does not require any cluster permissions https://github.com/sparkoo/kube-svcauth-proxy.

  • 👍🏻 only 1 extra sidecar per workspace
  • 👍🏻 no additional permissions or cluster permissions needed
  • 👍🏻 simple configuration
  • 👎🏻 custom component with all the stuff around it (productization, CQ, ...)

I have 2 alternatives to completely custom solution, but both solves just 1st issue with multiple streams:

  • use 2nd sidecar responsible for multiple stream routing. Something like traefik with forwardAuth to kube-rbac-proxy
    • 👎🏻 2 extra sidecars in the workspace
    • 👎🏻 still needs cluster permissions for kube-rbac-proxy
    • 👎🏻 complicated configuration of another component
    • 👍🏻 no custom component
  • custom component responsible for multiple streams and using kube-rbac-proxy as a library
    • 👎🏻 custom component with all the stuff around it (productization, CQ, ...)
    • 👎🏻 still needs cluster permissions
    • 👍🏻 only 1 extra sidecar

@sparkoo
Copy link
Member Author

sparkoo commented Sep 2, 2021

I've came up with different solution that will need only 1 extra container per workspace, no cluster permissions and no custom component. Additional sidecar is Traefik (which we already have in main che-gateway), which will take care of routing inside the workspace pod AND with forwardAuth will authorize request through kube-rbac-proxy in main che-gateway. Hopefully diagram is explains better how it works.

ℹ️ dotted line is forwardAuth check https://doc.traefik.io/traefik/middlewares/http/forwardauth/

route

@sparkoo
Copy link
Member Author

sparkoo commented Sep 17, 2021

fixed by eclipse-che/che-operator#1045

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/che-server kind/task Internal things, technical debt, and to-do tasks to be performed. severity/P1 Has a major impact to usage or development of the system.
Projects
None yet
Development

No branches or pull requests

5 participants