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

seccomp: add default profile #660

Closed
wants to merge 1 commit into from

Conversation

jessfraz
Copy link
Contributor

@jessfraz jessfraz commented May 24, 2017

Updates kubernetes/kubernetes#39845
Updates kubernetes/kubernetes#20870
Feature issue kubernetes/enhancements#135

This adds the notion of a default seccomp profile for kubernetes to the alpha seccomp support.

It details the various interactions with capabilities added to containers and covers some of the important syscalls that will be blocked by default.

Kinda related to the other sane hardening defaults set in #639 as well.

cc @timstclair

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 24, 2017
@timstclair
Copy link

/cc @kubernetes/sig-node-proposals @kubernetes/sig-auth-proposals

@k8s-ci-robot
Copy link
Contributor

@timstclair: These labels do not exist in this repository: sig/node, sig/auth.

In response to this:

/cc @kubernetes/sig-node-proposals @kubernetes/sig-auth-proposals

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. I understand the commands that are listed here.

@timstclair
Copy link

How will changes to the default profile work? It will be tricky to do in a way that doesn't risk breaking people on upgrade. Maybe the profile should be versioned? That's still not enough though, because changing defaults is hard... Upgrading a node shouldn't automatically replace the profile.

@jessfraz
Copy link
Contributor Author

jessfraz commented May 24, 2017 via email

@pweil-
Copy link
Contributor

pweil- commented May 24, 2017

How will changes to the default profile work?

The only
changes to the docker one

IIRC the use of any profile is a change unless folks are using PSP already (they probably aren't). So we'll need to solve the upgrade issue early.

@jessfraz
Copy link
Contributor Author

jessfraz commented May 24, 2017 via email

@pweil-
Copy link
Contributor

pweil- commented May 24, 2017

Obviously I'm not claiming that we will be so
lucky but it's a good sign.

Yeah, I think we're pretty safe. If the solution is "add the annotation and use unconfined again" I don't think that's a bad thing. It's just something folks need to be aware of.

@jessfraz
Copy link
Contributor Author

jessfraz commented May 24, 2017 via email

@timstclair
Copy link

The profile shouldn't need major changes once we deploy it.

Well now it's definitely going to need changes ;-) Hopefully if we get there though, we'll at least have first class support at the API level.

The docker default is represented in the annotation as docker/default. Will we add a new special annotation for this profile? (kubernetes/default? Just default?). Also, what will the deployment strategy be?

@jessfraz
Copy link
Contributor Author

jessfraz commented May 24, 2017 via email

@timstclair
Copy link

By deployment I meant how will we get the file on the nodes, but if we pass the spec through the CRI directly (rather than file path) then we don't need a file, and can just hard code it in the Kubelet (well, we could do that either way, but passing paths would require us to write it to disk somewhere). This has some crossover with the discussion on kubernetes/kubernetes#46332.

@jessfraz
Copy link
Contributor Author

jessfraz commented May 24, 2017 via email

@feiskyer
Copy link
Member

I think we should spec the seccomp format first before this. See kubernetes/kubernetes#39128 for some spec ideas.

@jessfraz
Copy link
Contributor Author

jessfraz commented May 25, 2017 via email

Signed-off-by: Jess Frazelle <acidburn@google.com>
### Spec

We will start from the OCI specification. This API resource will be added to
`settings.k8s.io` as an `alpha` resource.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just put this as a place holder but I have no idea where it belongs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also just added a spec but I am aware it needs more info with interaction with pods/containers and obviously examples but wanted to get early feedback, can add the rest as I get some time

Copy link
Member

@pmorie pmorie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to the initial version of the seccomp proposal that we wrote, so I think we should think about the same questions of whether we think we want to have an API resource complex enough to model a fully materialize seccomp profile. Personally, I think there's definitely some value in doing so.

I do think you might want to split some of the updates into a separate PR and/or split the new content into a distinct proposal, see comments.

FreeBSD has a seccomp/capability-like facility called
[Capsicum](https://www.freebsd.org/cgi/man.cgi?query=capsicum&sektion=4).


## Proposed Design

### Seccomp API Resource?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your proposal alters this text about API resources a bit, and I wonder if this ought to be a new proposal (as we have tended to do in the past when making proposals for new additions to a feature). So, we should probably either add some new text here that continues the narrative about what API resource we're adding, or split your net-new changes into a separate follow-on proposal.

* [docker/22109](https://github.com/docker/docker/issues/22109): composable
seccomp filters
* [docker/21105](https://github.com/docker/docker/issues/22105): custom
seccomp filters for builds

#### rkt / appcontainers
Implementation details:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good stuff; you may want to split the updates to the content out into a separate PR, since they're non-controversial and can easily be merged without depending on the new content here being accepted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya I was unsure what the protocol was for when things change but can totally split it out :)

`settings.k8s.io` as an `alpha` resource.

```
// Seccomp represents syscall restrictions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear whether this is global or namespaced - seems like namespaced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt should it be namespaced?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda feels a lot like storage classes which are not namespaced. @pmorie what makes it feel like namespaced? Multi-tenancy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference on namespaced or un-namespaced :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for non-namespaced, to match PodSecurityPolicy. It seems like something a ClusterAdmin should have control over... defining seccomp policies and then controlling who has permission to use them.

If an admin of a namespace has permission to create (and then use) new seccomp policies, they could potentially use known vulnerabilities in a multi-tenant cluster, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for resources to be both namespaced & unnamespaced?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for resources to be both namespaced & unnamespaced?

no

@bgrant0607
Copy link
Member

cc @destijl

Copy link
Contributor

@chrislovecnm chrislovecnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questiosn for you. Will be good to get this in.

| `keyctl` | Prevent containers from using the kernel keyring, which is not namespaced. |
| `lookup_dcookie` | Tracing/profiling syscall, which could leak a lot of information on the host. Also gated by `CAP_SYS_ADMIN`. |
| `mbind` | Syscall that modifies kernel memory and NUMA settings. Already gated by `CAP_SYS_NICE`. |
| `mount` | Deny mounting, already gated by `CAP_SYS_ADMIN`. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably being dense, but what do you mean as "gated by"? Will the gates allow mount for instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning it is also controlled by CAP_SYS_ADMIN
aka CAP_SYS_ADMIN is required to mount regardless

| `CAP_DAC_READ_SEARCH`| open_by_handle_at |
| `CAP_IPC_LOCK` | mlock, mlock2, mlockall |
| `CAP_SYS_ADMIN` | name_to_handle_at, bpf, clone, fanotify_init, lookup_dcookie, mount, perf_event_open, setdomainname, sethostname, setns, umount, umount2, unshare |
| `CAP_SYS_BOOT` | reboot |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only one that I would be raise a concern about. Do we have a usecase for reboot? But maybe I am overthinking it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's been in docker's default and there have been no complaints, do you reboot in a container, where is your cause for concern, just curious

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reboot the node or the container? And frankly I have never typed reboot inside a container.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's referring to the reboot syscall, which is not for containers because they aren't real :) http://man7.org/linux/man-pages/man2/reboot.2.html

`settings.k8s.io` as an `alpha` resource.

```
// Seccomp represents syscall restrictions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda feels a lot like storage classes which are not namespaced. @pmorie what makes it feel like namespaced? Multi-tenancy?

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 15, 2017
@bgrant0607
Copy link
Member

cc @davidopp

@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 22, 2017 via email

@k8s-github-robot
Copy link

@jessfraz PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 15, 2017
@tallclair tallclair mentioned this pull request Sep 23, 2017
22 tasks
Copy link
Member

@tallclair tallclair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jessfraz will you have bandwidth to drive this to completion in 1.10, or should we look for another owner?

Also, seccomp profiles can be layered, right? (Is no_new_privs required for that?) It might be useful to have a cluster-admin enforced default policy, but still allow devs to further tighten the restrictions with a custom profile layered on top.


If `capAdd` is used on a Container, the default profile will be adjusted to
interact accordingly with the capability added. These are documented below in
a table by the cap being added:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these capabilities are in the default set (e.g. CAP_CHOWN) - does that mean those syscalls would be allowed by default, or only if CAP_CHOWN is explicitly added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, the defaults would stay the same this was merely a reference.

`settings.k8s.io` as an `alpha` resource.

```
// Seccomp represents syscall restrictions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for resources to be both namespaced & unnamespaced?

@jessfraz
Copy link
Contributor Author

I will update this in the next few days I have bandwidth sorry for the delay.

@k8s-github-robot k8s-github-robot added the kind/design Categorizes issue or PR as related to design. label Feb 6, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 18, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 20, 2018
@cblecker
Copy link
Member

@jessfraz @tallclair Is this proposal still active? It's currently been rotting, and is slated to close 30d from now.

@jessfraz
Copy link
Contributor Author

jessfraz commented Mar 20, 2018 via email

@cblecker
Copy link
Member

@jessfraz Sounds good. I'll remove the label so this stays open

/remove-lifecycle rotten
/unassign sarahnovotny calebamiles

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Mar 20, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 18, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 18, 2018
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/design Categorizes issue or PR as related to design. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet