Skip to content

Docker security approach encourages privileged containers #6616

Closed

Description

@danbeaulieu

I am finding the default, immutable approach to capabilities that Docker takes ends up forcing users to use privileged containers. Docker removes many capabilities by default, and the only way to get them back is to use privileged containers which is most often overkill. Running privileged containers is recommended so frequently I think the implications are lost, leaving many users vulnerable. For instance, Apparmor is bypassed when using privileged containers...

It'd be nice to be able to turn on capabilities manually when running containers, this way it is obvious what users are doing, easier to reason about, and easier to manage the container security via other tools like Apparmor.

Activity

  1. gdm85 commented on Jun 23, 2014

    @gdm85
    Contributor

    Also for this issue I would like 'security' label.

    @danbeaulieu have you checked how LXC works? one should see if it's possible to expose functionality you intend through libcontainer...and keep in mind the portability plans of Docker development team...

  2. cpuguy83 commented on Jun 23, 2014

    @cpuguy83
    Member

    So yes, at one point there was even an "--opt" command flag in master which allowed configuring this stuff but was taken out due to UI/API discussions since it didn't seem polished enough.

    Lots of people want this.

  3. bgrant0607 commented on Jun 25, 2014

    @bgrant0607

    +1 to the principle of least privilege.

    Specification of capabilities at container instantiation time would be very useful, but not sufficient, however. Often applications will not run correctly if not granted the capabilities they require. We should adopt a principle that the container should specify its requirements/prerequisites for correct operation. Therefore, there should be Dockerfile syntax for required capabilities.

    Variable, optional, and context-specific configuration should be provided at instantiation time.

  4. cpuguy83 commented on Jun 25, 2014

    @cpuguy83
    Member

    And that would also require user authorization to allow said capabilities.

  5. bgrant0607 commented on Jun 25, 2014

    @bgrant0607

    Agreed, but decisions about whether to allow a given container need to be
    performed at a different layer, especially in a multi-user, multi-host,
    policy-rich environment.

    It would be fine by me if the capabilities granted also had to be specified
    at container instantiation time.

  6. michaelneale commented on Jun 26, 2014

    @michaelneale
    Contributor

    +1.

    Ideally privileged mode would be a special case of a more general feature: being able to blacklist capabilities. Dockers default now is to whitelist. Would be nice to have a mode which is explicitly blacklisting capabilities (but otherwise allowing things).

    User driven whitelisting would also be acceptable but perhaps less practical to use.

    Is anyone aware of any PRs working on this?

    Perhaps it is also worth surveying what people use priv mode for. For me it is usually VPN (eg openvpn) and systemd.

  7. danbeaulieu commented on Jun 26, 2014

    @danbeaulieu
    Author

    @michaelneale I'm not sure if anyone is working on this, but something similar has been alluded to on IRC and on the google group. @shykes mentioned a driver opts which would allow users to pass options directly down to the driver, not sure where that is in dev.

    I need privileged mode to allow mounting of a filesystem. Really the only capability I need is sys_admin, and I'd like to use AppArmor to limit the mounting capabilities, which I can do if I re enable AppArmor for privileged containers, but, like I said privileged is overkill for what I need. As it is now, I'm going to end up tuning AppArmor a lot more to prevent all the things in privileged I don't actually want.

    Can whoever has the power add the security label? It might get more attention from the community.

  8. cpuguy83 commented on Jun 26, 2014

    @cpuguy83
    Member

    Yes, this is being worked on, it's just a matter of people agreeing on the UI of it. The main work is already done and was even merged into master a few releases ago, but it got pulled because of UI concerns.

  9. danbeaulieu commented on Jun 26, 2014

    @danbeaulieu
    Author

    @cpuguy83 is there a discussion somewhere hashing out these concerns? I'd like to add my comments if possible and if it helps the discussion.

  10. cpuguy83 commented on Jun 26, 2014

    @cpuguy83
    Member

    It's probably on the docker-dev mailing list, I haven't looked at it though.

  11. cpuguy83 commented on Jun 26, 2014

    @cpuguy83
    Member
  12. cyphar commented on Jul 7, 2014

    @cyphar
    Contributor

    @michaelneale: why not just have some system where you can use wildcards so you can specify "allow all, except these". That is far more explicitly specifying that you are blacklisting. We should, at no point, be using blacklists for security features in Docker. That's just a bad idea.

  13. michaelneale commented on Jul 7, 2014

    @michaelneale
    Contributor

    @cyphar - agree re blacklists. Just as thing stands now - --privileged is being used almost by default just to get things working (which is worse than blacklisting - not saying blacklisting should be used!).

  14. cyphar commented on Jul 7, 2014

    @cyphar
    Contributor

    @michaelneale I understand that, That's why I like the way which #6687 is going. It's a whitelist, but you can also do wildcards and remove perms (thus allowing for admins to do blacklists).

  15. michaelneale commented on Jul 7, 2014

    @michaelneale
    Contributor

    Sounds great to me, very happy with that.

    On Monday, July 7, 2014, Aleksa Sarai [email protected] wrote:

    @michaelneale https://github.com/michaelneale I understand that, That's
    why I like the way which #6687
    #6687 is going. It's a
    whitelist, but you can also do wildcards and remove perms (thus allowing
    for admins to do blacklists).

    —
    Reply to this email directly or view it on GitHub
    #6616 (comment).

    Michael D Neale
    home: www.michaelneale.net
    blog: michaelneale.blogspot.com

  16. crosbymichael commented on Jul 16, 2014

    @crosbymichael
    Contributor

    This has now been implemented in --cap-add and --cap-drop. It's currently in master and should be out in the next docker release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions