A few weeks ago, I wrote a blog on removing capabilities from a container. But what if you want to add capabilities?
While I recommend that people remove capabilities, in certain situations users need to add capabilities in order to get their container to run.
One example is when you have a app that needs a single capability, like an Network Time Protocol (NTP) daemon container that resets the system time on a machine. So if you wanted to run a container for an ntp daemon, you would need to do a --cap-add SYS_TIME
. Sadly, many users don't think this through, or understand what it means to add a capability.
The most dangerous capability: SYS_ADMIN
Whenever I present on container security I explain that the power of root was originally broken into 32 separate capabilities. These capabilities were originally fairly fine grained. But two things conspired to make some of them become very powerful.
- As number of available capability slots were used up, the cost of using up a new capability versus just assigning a permission check to an existing capability increased.
- Kernel developers being lazy and not wanting to go through the hassle of allocating a new capability began to say stuff like: "This permission check is an admin function, I have a capability called SYS_ADMIN, I will just use that."
This led the SYS_ADMIN
capability to need two pages of the capability man page just to list the features given to a process with the SYS_ADMIN
check.
The main feature that containers take advantage of when removing the ability for processes inside of the container to mount new file systems.
Recently I received an email from a co-worker showing me what they could do with the SYS_ADMIN
capability.
Talking about selinuxfs, there is also an quick exploit that allows disabling the host selinux from a container, although so far it needs CAP_SYS_ADMIN (to mount selinuxfs) and without --selinux-enabled (like in previous overlayfs) in docker.
# docker run -it --rm --cap-add SYS_ADMIN rhel7 bash [root@d2b1fb6bd57c /] mount -t selinuxfs none /mnt [root@d2b1fb6bd57c /] getenforce Enforcing [root@d2b1fb6bd57c /] setenforce 0 [root@d2b1fb6bd57c /] getenforce Permissive [root@d2b1fb6bd57c /] exit # getenforce Permissive
(And we all know that disabling SELinux this makes me cry.)
Use Sparingly!
Bottom line: giving a process SYS_ADMIN capability is pretty close to removing all isolation. As a rule, you shouldn't do this, but it's helpful to know that you can if you need to for some reason.
저자 소개
Joe Brockmeier is the editorial director of the Red Hat Blog. He also acts as Vice President of Marketing & Publicity for the Apache Software Foundation.
Brockmeier joined Red Hat in 2013 as part of the Open Source and Standards (OSAS) group, now the Open Source Program Office (OSPO). Prior to Red Hat, Brockmeier worked for Citrix on the Apache OpenStack project, and was the first OpenSUSE community manager for Novell between 2008-2010.
He also has an extensive history in the tech press and publishing, having been editor-in-chief of Linux Magazine, editorial director of Linux.com, and a contributor to LWN.net, ZDNet, UnixReview.com, and many others.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.