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

Record seccomp profiles #46

Closed
saschagrunert opened this issue Jul 31, 2020 · 12 comments
Closed

Record seccomp profiles #46

saschagrunert opened this issue Jul 31, 2020 · 12 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Milestone

Comments

@saschagrunert
Copy link
Member

saschagrunert commented Jul 31, 2020

The idea is to allow the recording of seccomp profiles directly inside the Kubernetes cluster. To achieve that we could utilize the oci-seccomp-bpf-hook, which has the following requirements:

  • Kernel headers have to be installed (could be handled by the operator or the sysadmin)
  • An OCI hook compatible container runtime

We could think about annotating a node, then install the kernel headers (may be a prerequisite) and the hook. After that, the operator would have to annotate the target workload correctly (that's the way how the hook knows what to do). The recorded profile would have to be written into a configmap afterwards, which would cause that all nodes sync the profile to disk.

WDYT? It's overall a bit complicated but seems like a valuable feature after the initial release.


Edit: We could also use the seccomp notifier feature to think about a more elegant way to record profiles. This needs more evaluation but might be achievable by creating a PID namespace-shared sidecar.

@saschagrunert saschagrunert added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 31, 2020
@saschagrunert
Copy link
Member Author

/priority important-longterm

@k8s-ci-robot k8s-ci-robot added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Jul 31, 2020
@pjbgf
Copy link
Member

pjbgf commented Jul 31, 2020

This method is ideal for long running containers which would be "monitored" as its functionality is being used, as it only captures the syscalls made during the execution of the container being observed. The more permutations of execution paths ran, the more accurate will be the resulting profile.

A challenge on using seccomp-bpf-hook on a cluster is that it will need to run as root and with CAP_SYS_ADMIN capability, which effectively allows that container to bypass a considerable amount of security isolation primitives in the nodes. This can put end-users at risk if they were to decide using such feature in production or mixed usage clusters/nodes.

Ideally such approach would be used on ephemeral non-production clusters with the assistance of E2E tests which would be executed against the container being observed.

@saschagrunert
Copy link
Member Author

Moving to v2.

@saschagrunert saschagrunert added this to the v2 milestone Aug 7, 2020
@saschagrunert
Copy link
Member Author

saschagrunert commented Aug 31, 2020

cc @rhafer @ereslibre @mrostecki

@moolen
Copy link

moolen commented Oct 1, 2020

I did a bit of reasearch, i just want to cross-reference them:

@saschagrunert
Copy link
Member Author

Interesting approaches @moolen and thank you for the insights. 🙏 From my perspective the most clean way would be to let containerd suppport OCI hooks, where I see no major blockers for it. 🤷

@rhafer
Copy link
Contributor

rhafer commented Oct 2, 2020

A challenge on using seccomp-bpf-hook on a cluster is that it will need to run as root and with CAP_SYS_ADMIN capability, which effectively allows that container to bypass a considerable amount of security isolation primitives in the nodes. This can put end-users at risk if they were to decide using such feature in production or mixed usage clusters/nodes.

@pjbgf Isn't it only the hook itself that needs CAP_SYS_ADMIN (in order to setup the bpf tracer). IIUC this doesn't mean that the container itself needs the CAP_SYS_ADMIN capability.

@rhafer
Copy link
Contributor

rhafer commented Oct 2, 2020

I did a bit of reasearch, i just want to cross-reference them:

Yeah, that might be worth a look. Another option would be to utilize the seccomp notifcation mechanism (as already mentioned in initial post), but that does require some changes on lower level runtimes (runc, crun, ...)

  • we could talk to containerd directly to get a PID and inject the eBPF tracer after the container starts (far from ideal, but currently possible)

Hm, I guess at that point it might already have missed a couple of syscalls? So result would be imcomplete. I agree with @saschagrunert here, it would be cool if containerd would finally get support for oci-hooks.

@pjbgf
Copy link
Member

pjbgf commented Oct 9, 2020

@pjbgf Isn't it only the hook itself that needs CAP_SYS_ADMIN (in order to setup the bpf tracer). IIUC this doesn't mean that the container itself needs the CAP_SYS_ADMIN capability.

Very fair observation. Overall my concern is that requiring users to have something running with CAP_SYS_ADMIN capability within their clusters may lead a few potential route of privesc/security features bypass that cannot go unchecked. This is not a show stopper in itself, however we need to think what compensating controls we would put in place to limit potential damage.

Once we get to a working prototype we can brainstorm around it.

@saschagrunert saschagrunert modified the milestones: v0.2.0, v0.3.0 Dec 3, 2020
@saschagrunert
Copy link
Member Author

/assign
I'll take over the work from @rhafer :)

@saschagrunert
Copy link
Member Author

Let's close this for now, more enhancements to the feature to come.
/close

@k8s-ci-robot
Copy link
Contributor

@saschagrunert: Closing this issue.

In response to this:

Let's close this for now, more enhancements to the feature to come.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants