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

Plugin Isolation #1021

Closed
huseyinbabal opened this issue Mar 20, 2023 · 0 comments
Closed

Plugin Isolation #1021

huseyinbabal opened this issue Mar 20, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@huseyinbabal
Copy link
Contributor

huseyinbabal commented Mar 20, 2023

We are going to introduce file system isolation to prevent other plugins from using default Botkube SA.

In this case, Botkube app needs to use root permissions inside the container, which could be a security concern for some. We accept this a less evil.

This will prevent accidental bugs in plugins:

  • plugins won’t be allowed to read e.g. Slack and Discord credentials
  • Plugins won’t be allowed to use Botkube Pod ServiceAccount

LIMITATION: Plugins will use their own kubeconfig with user and groups, but they can still alter the Kubeconfig to use different user or group. As a result, you need to anyway trust the plugins that you install.

AC

  • introduce a plugin isolation system as described in the proposal here.
  • Update the documentation and state clearly, that:
    • Botkube uses impersonation
    • How plugins are isolated, and what are the limitations
    • User needs to trust each plugin as they can alter the kubeconfig and use different permissions
    • Consider describing it in a “Security” doc and link from RBAC docs
    • Nice to have: diagrams
  • Add e2e tests using echo plugin. It can be renamed. However, the idea is to run bash command through the echo executor to check that we get denied error.
  • Fix bugs that will be uncovered by added isolation:

Research Result
In this research, I created dedicated folders for each plugin and downloaded the binaries there to do proper chroot operation. I tried use chroot with plugin cmd, but no result due to;

  • Hashicorp Go Plugin has an abstraction on plugin execution, so even you have cmd with chroot settings, it gives an error

Image

Image

  • Even you somehow fork the Hashicorp Go Plugin repo and do chroot, you need to copy all basic executables from the root, to the chrooted directory. Assume you built a tree plugin that shows directory in tree format and it needs ls command. For this case, you need to do cp /bin/ls /tmp/botkube/tree/bin/ls for tree plugin since it uses builtin ls command. This is not flexible especially once you can implement different kind of plugins that needs different dependencies.

Is CMD without Chroot a Real Concern?
I don't think so, even Terraform itself does not use chroot as you can see here, we don't need to spend too much effort on this. In same way, as an example, Akamai provider has direct access to read env vars as you can see here.

What is the output?
We can omit chroot support, but there is still one more item which is changing the default k8s token to prevent random access by plugins.

@huseyinbabal huseyinbabal converted this from a draft issue Mar 20, 2023
@pkosiec pkosiec added the enhancement New feature or request label Mar 28, 2023
@mszostok mszostok added this to the v1.1.0 milestone Apr 21, 2023
@mszostok mszostok added the needs-triage Relates to issues that should be refined label Apr 21, 2023
@mszostok mszostok moved this to Todo in Botkube Apr 21, 2023
@mszostok mszostok removed the needs-triage Relates to issues that should be refined label Apr 24, 2023
@huseyinbabal huseyinbabal moved this from Todo to In Progress in Botkube May 9, 2023
@huseyinbabal huseyinbabal self-assigned this May 9, 2023
@pkosiec pkosiec modified the milestones: v1.0.1, v1.1.0 May 15, 2023
@huseyinbabal huseyinbabal moved this from In Progress to To Review in Botkube May 22, 2023
@pkosiec pkosiec closed this as completed Jun 12, 2023
@github-project-automation github-project-automation bot moved this from To Review to To Release in Botkube Jun 12, 2023
@pkosiec pkosiec moved this from To Release to Done in Botkube Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

3 participants