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

modify default label for containers #1318

Merged
merged 2 commits into from
Feb 17, 2021

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Feb 11, 2021

Issue number:
N/A

Description of changes:
The goal here is to better align our SELinux policy transitions with the behavior of Docker and containerd's CRI plugin, which expect that privileged containers will take the default path and end up with a more powerful label, while unprivileged ones will allocate an MCS pair that facilitates isolation between containers.

Although we don't yet support MCS isolation, this lays the groundwork for that by introducing a distinct label for privileged containers. That will let us add more restrictions to the container_t type, such as MCS constraints, without simultaneously restricting the control_t type in ways that are incompatible with expectations in the ecosystem.

Note that control_t and privileged are already quite similar in terms of their ability to affect the system: control_t offers highly privileged access to the host by means of the API, while privileged containers can bypass many access controls without using the API.

Instead of repurposing the control_t type and granting the additional permissions to privileged containers, we could define a new type, such as privileged_t. Maintaining a separate but similar label would require duplicating many additional rules over time; for example, both labels would need access to host sockets, and both would need to be able to bypass MCS constraints.

Testing done:
I verified that Docker now uses control_t for "privileged" and "label disabled" containers.

As part of the work to update to containerd 1.4, I also verified that control_t is used for privileged containers launched via CRI. Until then, container_t will continue to be used because of our SELinux patches on containerd 1.3.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

packages/selinux-policy/rules.cil Outdated Show resolved Hide resolved
Copy link
Contributor

@jhaynes jhaynes left a comment

Choose a reason for hiding this comment

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

I'll echo @tjkirch's comment on expanding the explanation of the expected behavior.

@bcressey bcressey force-pushed the default-container-label branch 2 times, most recently from 1a0f7e9 to 0a5aabb Compare February 16, 2021 00:15
@bcressey
Copy link
Contributor Author

bcressey commented Feb 16, 2021

The two force pushes together are what I intended to be a rebase with no changes. I'll push the actual changes for this PR shortly.

packages/selinux-policy/lxc_contexts Outdated Show resolved Hide resolved
This changes the default label from `container_t`, which is meant as
the unprivileged type, to `control_t`, which has higher privileges,
including the ability to write to the host API socket.

This is better aligned with the SELinux logic in containerd's CRI
plugin and in the docker daemon, where the label from lxc_contexts is
used for unprivileged containers, while privileged containers are not
explicitly labeled and follow the default transition rules.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
This documents the switch to running privileged containers with the
`control_t` label by default, and describes the implications.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
@bcressey bcressey merged commit cf99036 into bottlerocket-os:develop Feb 17, 2021
@bcressey bcressey deleted the default-container-label branch February 17, 2021 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants