Fine grained control over capabilities (--cap-add, --cap-drop)
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
Would really like to see this. I need to add SYS_PTRACE to a machine that contains tracing instrumentation.
+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 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
+1 for this, especially --cap-add SYS_ADMIN --device
+1 because i like to have --cap-add LINUX_IMMUTABLE for security improvements that will help many people sleep better at night :+1:
+1
+1
+1 to this. Is it being worked on? I'm surprised there is no way currently to remove unneeded capabilities in ECS.
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?
+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.
Instead of having to make modifications for each option added to docker, why not just allow people to arbitrarily set the list of flags?
+1 Looking for --cap-add=IPC_LOCK
+1
Opened almost 2 years ago at this point. Any status update?
We need --cap-add SYS_PTRACE to view syscall info, as we can not run container in privileged mode. Please do something about this.
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.
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.
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.
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/
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.