Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Kubernetesのセキュリティのベストプラクティス
Ian Lewis
March 08, 2018
Technology
12
16k
Kubernetesのセキュリティのベストプラクティス
Ian Lewis
March 08, 2018
Tweet
Share
More Decks by Ian Lewis
See All by Ian Lewis
Kubernetes Security Best Practices
ianlewis
38
25k
The Enemy Within: Running untrusted code in Kubernetes
ianlewis
0
1k
The Enemy Within: Running untrusted code with gVisor
ianlewis
4
620
KubeCon EU Runtime Track Recap
ianlewis
3
1.2k
コンテナによるNoOpsオートメーション
ianlewis
2
120
Google Kubernetes Engine 概要 & アップデート @ GCPUG Kansai Summit Day 2018
ianlewis
2
690
Extending Kubernetes with Custom Resources and Operator Frameworks
ianlewis
10
3.2k
Scheduling and Resource Management in Kubernetes
ianlewis
2
1.3k
Keynote: The Kubernetes Community
ianlewis
0
150
Other Decks in Technology
See All in Technology
ReverseETLでユーザーに価値を届ける基盤を実現した話
hakky
0
330
金融領域のマルチプロダクトを効率よく開発・運用するためのシステム基盤と組織設計について / 2022-07-28-multi-product-platform
stajima
0
140
最先端の生成AIから考える、ビジネスにおける10年後のパラダイムシフト
sbtechnight
1
310
私のAWS愛を聞け! ~ここが好きだよStep Functions~ #devio2022
kongmingstrap
0
270
Simplify Cloud Native Security with Trivy
knqyf263
0
490
今 SLI/SLO の監視をするなら Sloth が良さそうという話
shotakitazawa
0
260
eBPFで実現するコンテナランタイムセキュリティ / Container Runtime Security with eBPF
tobachi
PRO
5
1.5k
セキュアなTerraformの使い方 ~ 機密情報をコードに含めず環境構築するにはどうしたらいいの?
harukasakihara
8
1.2k
ECS Fargate+Mackerelにおける監視費用を削減するまでの話
nulabinc
PRO
1
160
増田亨さんによる 「設計の考え方とやり方」勉強会オープニング
tsuyok
0
190
聊聊 Cgo 的二三事
david74chou
0
330
脆弱性スキャナのOWASP ZAPを コードベースで扱ってみる / OWASP ZAP on a code base
task4233
1
200
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
213
7.5k
What's new in Ruby 2.0
geeforr
336
30k
GitHub's CSS Performance
jonrohan
1020
420k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
173
8.6k
jQuery: Nuts, Bolts and Bling
dougneiner
56
6.4k
The Cult of Friendly URLs
andyhume
68
4.8k
Building a Scalable Design System with Sketch
lauravandoore
448
30k
Build The Right Thing And Hit Your Dates
maggiecrowley
19
1.2k
Three Pipe Problems
jasonvnalue
89
8.7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
237
19k
Product Roadmaps are Hard
iamctodd
35
6.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
39
13k
Transcript
Kubernetesのセキュリティ ベストプラクティス ianmlewis@
Ian Lewis • ianlewis@ • Google • Tokyo, Japan •
#kubernetes, #go, #python
Kubernetes • コンテナ オーケストレーション • インフラ API/ フレームワーク
Guestbookアプリ • Web Frontend ◦ ウェブアプリ ◦ HTML/JS/CSS • Message
◦ メッセージを 保存・閲覧 • NGWord ◦ NG ワードを 検出する Kubernetes Cluster Web Frontend Redis NGWord message
Kubernetes API Server 1. フロントエンド Pod から トークンを取得 2. トークンを利用し、
API サーバーを攻撃 3. シークレットなどを取得 し、さらに サービスを攻撃 Kubernetes Cluster Web Frontend Redis NGWord message ① ② ③
Mitigate 1 & 2: RBAC • Role Based Access Control
• ユーザーやサービスアカウントへロールを付与 • ロールが権限を持つ ◦ get secrets ◦ update configmap ◦ etc. • RBAC 設定はネームスプペース範囲 • GKE では IAM と連携
Mitigate 1 & 2: RBAC ClusterRole ClusterRoleBinding 1:many many:1 Verb
+ Type
Mitigate 2: API Server Firewall • API サーバーへのアクセスを IP アドレスに制限
• GKE: ◦ gcloud container clusters create --enable-master-authorized-networks --master-authorized-networks=....
Mitigate 3: Network Policy • データベースへのアクセスを必要のある Pod に制限 • ラブルセレクターで
Pod を選択 • ネットワークプラグインで実装されてる : Calico, Weave, etc.
NetworkPolicy kind: NetworkPolicy apiVersion: networking.k8s.io/v1 metadata: name: redis spec: podSelector:
matchLabels: name: redis ingress: - from: - podSelector: matchLabels: name: guestbook
ホストへアクセス 1. コンテナ外へ突破 2. Kubelet を攻撃 3. 同じホストに実行中の コンテナを攻撃 Host
Web Frontend
Mitigate 1: non-rootユーザーで実行 apiVersion: v1 kind: Pod metadata: name: security-context-demo
spec: securityContext: runAsUser: 1000
Mitigate 1: 読込専用ファイルシステム apiVersion: v1 kind: Pod metadata: name: security-context-demo
spec: securityContext: readOnlyRootFilesystem: true
Mitigate 1: no_new_privs apiVersion: v1 kind: Pod metadata: name: security-context-demo
spec: securityContext: allowPrivilegeEscalation: false
Mitigate 1: 組み合わせ apiVersion: v1 kind: Pod metadata: name: security-context-demo
spec: securityContext: runAsUser: 1000 readOnlyRootFilesystem: true allowPrivilegeEscalation: false
Your App Container seccomp Mitigate 1: seccomp/ AppArmor/ SELinux AppArmor/
SELinux
seccomp apiVersion: v1 kind: Pod metadata: name: mypod annotations: seccomp.security.alpha.kubernetes.io/pod:
runtime/default ...
AppArmor apiVersion: v1 kind: Pod metadata: name: mypod annotations: container.apparmor.security.beta.kubernetes.io/hello:
runtime/default spec: containers: - name: hello ...
SELinux apiVersion: v1 kind: Pod metadata: name: mypod spec: securityContext:
seLinuxOptions: level: "s0:c123,c456" containers: - name: hello ...
Mitigate 2 & 3: Kubeletの権限を制限する • RBAC for Kubelet: ◦
--authorization-mode=RBAC,Node --admission-control=...,NodeRestriction • Rotate Kubelet certs: ◦ kubelet … --rotate-certificates
Unsecured Pods • You follow the rules but others don't
Kubernetes Cluster Web Frontend Redis NGWord message
Mitigate: PodSecurityPolicy apiVersion: extensions/v1beta1 kind: PodSecurityPolicy metadata: name: example spec:
privileged: false # Don't allow privileged pods! # The rest fills in some required fields. seLinux: rule: RunAsAny supplementalGroups: rule: RunAsAny runAsUser: rule: 1000 fsGroup: rule: RunAsAny volumes: - '*'
istio • Service mesh • Envoy proxy 組み込み
トラフィクを傍受 1. ネットーワーク上の通 信を傍受 2. あるサビースに不正リ クエストを送る Kubernetes Cluster Web
Frontend Redis NGWord message
istio 1. サービス間の プロクシー 2. 暗号化 3. 証明書の自動更新 4. ポリシーが
セントラルサーバで集 中して管理する Kubernetes Cluster Web Frontend Redis NGWord message
Thanks!