<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[PinaClouda - Medium]]></title>
        <description><![CDATA[雲端工程 Kubernetes 的知識典 - Medium]]></description>
        <link>https://medium.com/web-application?source=rss----b226475cc626---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>PinaClouda - Medium</title>
            <link>https://medium.com/web-application?source=rss----b226475cc626---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:51:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/web-application" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A security problem with KubeDNS]]></title>
            <link>https://medium.com/web-application/a-security-problem-with-kubedns-2f2157b16a1?source=rss----b226475cc626---4</link>
            <guid isPermaLink="false">https://medium.com/p/2f2157b16a1</guid>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[coredns]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Ewing Lin]]></dc:creator>
            <pubDate>Tue, 17 Nov 2020 11:31:49 GMT</pubDate>
            <atom:updated>2020-11-17T11:31:48.948Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SIjgJ_2w278D36pYujlKGw.png" /></figure><p>DNS，現代網路世界中的核心技術之一，其主要功能像是將 hostname 轉換成 IP 位址，讓使用者能不需要記住純數字的 IP 位址便能輕鬆的漫遊網路。如此重要的系統當然必須要有較為全面的安全性考量。</p><p>今天我們來說說 KubeDNS 作為早期 k8s 的標準配備所擁有的一項安全問題。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ucbNOF5tC5oOm7q6mEQxAw.png" /></figure><p><strong>KubeDNS</strong>，Kubernetes 最早的 DNS Server，在 k8s v1.12 時正式被 CoreDNS 取代。這其中包括相當多的原因</p><ul><li>KubeDNS 是由三個 containers 所組成的，而 CoreDNS 卻只有一個¹</li><li>Kube-dns 使用的 dnsmasq 是 single threaded C code，而 CoreDNS 則是multi-threaded Golang</li><li>CoreDNS 的 negative caching 是預設的，KubeDNS卻不是</li></ul><p>總結而言，這些導致 CoreDNS 效能相較 KubeDNS 要差上一些。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*Wam-TKJuSptMmXIqAQeUog.jpeg" /></figure><h3><strong>撇開功能與效能的差距，Security 也是非常重要的一個考量。</strong></h3><p>在現代軟體業中，為了更加快速的開發新功能，安全性往往會被人們忽略。而我們在適應 Microservices 的過程中又不得不與 container 們天天打交道。這樣的結果導致各式各樣的 attack 的讓我們不得不處處堤防。</p><p><strong><em>IMO, the basic rule of container security is to run with least privilege.</em></strong></p><p>說到<strong><em> Least Privilege </em></strong>最小權限原則，我們來看看作為一個 k8s 內部的 DNS Server，到底有哪些權限是必須的呢？</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nk7SQtLW-xw2j6Of.png" /></figure><p>我們來看看 kOps，一個常見的 k8s operation 工具，是如何設定的CoreDNS的。簡單的說我們除了需要使用 DNS 常見的 port 53 以外，任何 Linux Capabilities 都是多餘的。（順帶一提其實 NET_BIND_ADMIN 也並非必須）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-D-8XetyZF4pX4tJWwAtEg.png" /></figure><p>這裡我們其實可以了解到大多數 application 是不需要任何 Linux Capability 的。²</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/0*YaiQ6lnj0XJ75Fxn" /></figure><p>了解了上面的基本後我們來說說 KubeDNS 究竟存在著什麼問題呢？</p><h4><a href="https://github.com/kubernetes/dns/issues/190">kube-dns cannot run as non-root user #190</a>³</h4><p>是的！Container Security 中最基本的元則之一硬生生的被打破了。<br>KubeDNS 最為 k8s cluster 中極其容易被當作攻擊目標的 container 卻必須使用 UID 0 來運行。<br>這代表每當我們的 KubeDNS 被如入侵後，attacker 將能更加容易的在突破 container 並且控制我們的 k8s host。And attack follows on ! 從 DNS resolution下手再到 Node Control，在不知不覺的情況下你正在把自己客戶的重要資料免費送給有心人🤯。</p><p>所以如果你的 k8s cluster 還在使用 KubeDNS 作為 DNS Server 的話，在這裡建議可以考慮趕快換成 CoreDNS 喔！</p><p>這裡附上 <a href="https://kubernetes.io/docs/tasks/administer-cluster/coredns/">CoreDNS Migration Guide</a> ~</p><p>[1] <a href="https://coredns.io/2018/11/27/cluster-dns-coredns-vs-kube-dns/#:~:text=CoreDNS%20is%20a%20single%20container,caching%20in%20the%20default%20deployment">https://coredns.io/2018/11/27/cluster-dns-coredns-vs-kube-dns/#:~:text=CoreDNS%20is%20a%20single%20container,caching%20in%20the%20default%20deployment</a>.</p><p>[2] <a href="https://github.com/kubernetes/kops/blob/42902f55991ed15341c93a50cbd5ee17d3c0b975/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.12.yaml.template#L195">https://github.com/kubernetes/kops/blob/42902f55991ed15341c93a50cbd5ee17d3c0b975/upup/models/cloudup/resources/addons/coredns.addons.k8s.io/k8s-1.12.yaml.template#L195</a></p><p>[3] <a href="https://github.com/kubernetes/dns/issues/190">https://github.com/kubernetes/dns/issues/190</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f2157b16a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/web-application/a-security-problem-with-kubedns-2f2157b16a1">A security problem with KubeDNS</a> was originally published in <a href="https://medium.com/web-application">PinaClouda</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>