amazon-ecs-agent icon indicating copy to clipboard operation
amazon-ecs-agent copied to clipboard

Fine grained control over capabilities (--cap-add, --cap-drop)

Open adrienkohlbecker opened this issue 11 years ago • 35 comments

Hello,

Support for privileged mode was introduced recently, which is nice. However, there is no support for --cap-add and --cap-drop in the configuration, which allows for a more fine grained control over what's allowed or not. Moreover, --privileged changes some AppArmor and SELinux settings, which might not be needed in all cases.

My use case is simple, I don't need --privileged, I just need --cap-add=SYS_ADMIN to be able to umount a volume.

Best

adrienkohlbecker avatar Oct 14 '15 12:10 adrienkohlbecker

Would really like to see this. I need to add SYS_PTRACE to a machine that contains tracing instrumentation.

jessesanford avatar Nov 20 '15 19:11 jessesanford

+1 for this

We want to support mounting FUSE filesystems which only needs --cap-add SYS_ADMIN --device to acess /dev/fuse, not full-blown --privileged.

mattmanning avatar Feb 11 '16 17:02 mattmanning

@mattmanning FYI, you will probably also need a custom seccomp profile with docker >= 1.10 https://github.com/docker/docker/issues/20092 https://github.com/docker/docker/issues/20082

adrienkohlbecker avatar Feb 11 '16 18:02 adrienkohlbecker

+1 for this, especially --cap-add SYS_ADMIN --device

aboutvale avatar May 24 '16 13:05 aboutvale

+1 because i like to have --cap-add LINUX_IMMUTABLE for security improvements that will help many people sleep better at night :+1:

noreabu avatar May 27 '16 10:05 noreabu

+1

adamjkeller avatar Aug 25 '16 17:08 adamjkeller

+1

aaronsturm avatar Aug 25 '16 21:08 aaronsturm

+1 to this. Is it being worked on? I'm surprised there is no way currently to remove unneeded capabilities in ECS.

eukaryote avatar Oct 30 '16 02:10 eukaryote

Guys, please don't +1 comments unless you have something else to add; it gets noisy.

Use GitHub's comment-emoji feature.

Can anyone comment on if this is in the works?

voltechs avatar Nov 09 '16 16:11 voltechs

+1 - From a general security perspective, we should have the ability to drop all unused privileges for any container/application. In our current case, we need NET_ADMIN to futz with the container's network namespace. Running a web facing container in privileged mode is a show stopper for ECS.

ChristopherMotes avatar Nov 23 '16 14:11 ChristopherMotes

Instead of having to make modifications for each option added to docker, why not just allow people to arbitrarily set the list of flags?

herriojr avatar Feb 27 '17 20:02 herriojr

+1 Looking for --cap-add=IPC_LOCK

ebekker avatar May 01 '17 22:05 ebekker

+1

liorchen avatar Jun 15 '17 06:06 liorchen

Opened almost 2 years ago at this point. Any status update?

corydodt avatar Jun 30 '17 05:06 corydodt

We need --cap-add SYS_PTRACE to view syscall info, as we can not run container in privileged mode. Please do something about this.

singhjagmohan1000 avatar Jul 25 '17 21:07 singhjagmohan1000

Thanks for all the comments here! We've been looking into how to support this and think we'll take the following approach:

  • We'll add new fields to the task definition to indicate Linux capabilities to add and drop
  • We'll add a way for the ECS agent to indicate what capabilities are known by the kernel; this will ensure that a given task definition is actually placeable on your container instances
  • The ECS agent may auto-detect capabilities or allow you to specify which ones matter to you. Since the set of capabilities that are possible is pretty large, we'd appreciate feedback as to whether everything should be auto-detected or not. Another approach could be letting the agent auto-detect the most common capabilities and also let you specify the other required capabilities.

Your input is highly appreciated.

sharanyad avatar Jul 28 '17 21:07 sharanyad

IMO it's not actually worth auto-detecting and registering support of individual capabilities. The list of capabilities that the kernel supports really doesn't change very much over time. The commit history for the capabilities manpages suggests that no new capabilities have been added since at least 2014, and the majority of them are much older than that.. I think we're over-engineering the solution if we try to handle the list dynamically.

It's notable that Docker itself doesn't try to do anything clever around detection of capability support either.

nmeyerhans avatar Jul 28 '17 22:07 nmeyerhans

The only one of the three bullet points that I would make use of is the first one:

  • We'll add new fields to the task definition to indicate Linux capabilities to add and drop

Also, please don't overlook 'ALL' as an option.

I'd prefer a simple implementation that just passes through the capabilities to Docker as provided. I know which kernel versions I run, which capabilities they support, and which I want to add and remove for a given task, and I want exactly the ones I specify to be passed to Docker, with no possibility of ecs-agent doing anything clever that results in something other that what I specified being used.

eukaryote avatar Jul 29 '17 18:07 eukaryote

We want to do --cap-drop=all --cap-add=sys_ptrace

See also: http://rhelblog.redhat.com/2016/10/17/secure-your-containers-with-this-one-weird-trick/

lawrencepit avatar Aug 14 '17 07:08 lawrencepit

While running Vault I'd like to drop several but add IPC_LOCK. I could just enabled privileged but that adds a bunch of capabilities it doesn't need.

jhmartin avatar Sep 07 '17 22:09 jhmartin