openshift s2i 漏洞小窺
今天在openshift群里看到這個Critical的issue:https://access.redhat.com/security/vulnerabilities/3422241,這是一個S2I安全漏洞,它會影響到OpenShift Container Platform 3.0-3.9,研究了一下,分享一下自己的體會,本文只代表個人觀點。
openshift提供openshift-sti-build模塊,實現從代碼構建到生成應用鏡像的功能。在S2I構建部分,會啟動/openshift/ose-sti-builder容器,此容器是以privilege許可權運行,完成後,此容器即退出。
結合源碼閱讀,openshift-sti-build將調用ExtractTarStreamFromTarReader方法,解壓tar文件到/tmp目錄,這樣,在/tmp中用戶文件就具有root root許可權。以此發生了privilege escalation。
下面是openshift工程師的分析:
*Flaw is not in the GO tar implementation but is in the failure to restrict the execution context. The writing is done by a process with inflated privileges. S2I in general has too many privileges for a service that processes Turing complete user input.* Major area of concern is within S2I, but other affected areas are known to exist.
這個問題同時存在在"kubelet cp","oc cp" "oc rsync"等操作,參見相關的bug:
https://github.com/kubernetes/kubernetes/issues/61297
https://bugzilla.redhat.com/show_bug.cgi?id=1562246
這個問題發現者Michael Hanselmann相關的blog見如下:
https://hansmi.ch/articles/2018-04-openshift-s2i-security
問題的解決是對openshift-sti-build組件進行升級,同時,我們可以小窺一下openshift組件升級的過程。
openshift-sti-build以容器方式運行在每個node節點上,如果鏡像正在被使用,可以通過docker tag對鏡像添加任意一個tag,再刪除鏡像將不會影響正在運行的容器。大致過程如下:
$ BADIMAGE=cee523a4e55c$ BADVERS=v3.3.46.38$ sudo docker tag $BADIMAGE registry.access.redhat.com/openshift3/ose-sti-builder:donotuse$ sudo docker rmi registry.access.redhat.com/openshift3/ose-sti-builder:$BADVERS
之後,通過openshift提供的ansible腳本進行組件自動升級。
推薦閱讀:
※kubernetes1.9源碼閱讀 kubernetes的watch包
※關於GitHub遷移到K8S的最佳實踐,你最看重哪方面?
※Kubernetes v1.7新特性解析-自定義Hosts
※Kubernetes dashboard更新升級和用戶許可權認證
※適用於kubernetes的應用開發部署流程同時集成Istio service mesh——如何開發kubernetes native應用
TAG:Kubernetes |
