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

docker: privileged containers should have SELinux #1013

Merged

Conversation

samuelkarp
Copy link
Contributor

Issue number:
Fixes: #1011

Description of changes:
By default, Docker injects the equivalent of --security-opt label:disable for containers launched with the --privileged option with the intent of providing as much privilege as possible. This option disables both process and mount labeling for the container. Unfortunately, disabling labeling does not provide additional privileges when Bottlerocket's SELinux policy is enforced but instead reduces privileges. This change removes the injection of the label:disable option so privileged containers receive the same default labels as non-privileged containers.

To launch a container with all SELinux labeling disabled, the explicit --security-opt label:disable can still be used.
To launch a container with a label that provides additional privileges,--security-opt label:type:super_t can be used.

Testing done:
On both an aws-dev instance and an aws-ecs-1 instance:

  • Run a non-privileged container with no explicit label. Verify that the mount receives the implicit local_t label. Verify that writing to the rootfs works.
  • Run a privileged container with no explicit label. Verify that the mount receives the implicit local_t label. Verify that writing to the rootfs works.
  • Run a non-privileged container with --security-opt label:disable. Verify that the mount does not receive the local_t label. Verify that writing to the rootfs is denied.
  • Run a privileged container with --security-opt label:disable. Verify that the mount does not receive the local_t label. Verify that writing to the rootfs is denied.
  • Run a non-privileged container with --security-opt label:type:super_t. Verify that the mount receives the implicit local_t label. Verify that writing to the rootfs works. Verify that writing to a restricted host path like /etc works.
  • Run a privileged container with --security-opt label:type:super_t. Verify that the mount receives the implicit local_t label. Verify that writing to the rootfs works. Verify that writing to a restricted host path like /etc works.

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.

By default, Docker injects the equivalent of --security-opt
label:disable for containers launched with the --privileged option with
the intent of providing as much privilege as possible.  This option
disables both process and mount labeling for the container.
Unfortunately, disabling labeling does not provide additional privileges
when Bottlerocket's SELinux policy is enforced but instead reduces
privileges.  This change removes the injection of the label:disable
option so privileged containers receive the same default labels as
non-privileged containers.

To launch a container with all SELinux labeling disabled, the explicit
--security-opt label:disable can still be used.
To launch a container with a label that provides additional privileges,
--security-opt label:type:super_t can be used.

Fixes: bottlerocket-os#1011
@samuelkarp samuelkarp merged commit 22fe9f9 into bottlerocket-os:develop Aug 10, 2020
@samuelkarp samuelkarp deleted the docker-privileged-label branch August 10, 2020 16:42
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.

privileged containers running under Docker cannot write to their rootfs
3 participants