1 How to secure your Kubernetes cluster on Google Cloud セキュアなGKEクラスタのつくりかた Mercari Security Engineering 末澤 裕希 (@rung) Oct 14, 2021 Google × Mercari に学ぶ! Kubernetesの活用法とセキュリティ v1.00
10 ● Single Cluster: 複数のMicroservices(チーム)が同じクラスタを利用 ○ Kubernetes(Google Kubernetes Engine)を利用 ○ 2017年より本格運用 Kubernetes Clusters on Mercari API gateway Authority Service A Spanner Google Kubernetes Engine Cloud SQL Service B
13 Node Kubernetes Runtime Security ● 目標: Isolation(分離) の実現 ○ 様々なMicroservicesが同一クラスタに同居 ○ 各Microservicesが影響を及ぼせる範囲を最小限に Team A Team B Team C SRE Microservice A Namespace A Microservice B Microservice C Cluster Monitoring SRE Namespace Deployment Tool Least Privilege Namespace B Namespace C Defense in Depth
14 一般的なコンテナのコンセプト Guest OS Linux Node Process 1 (Host) Process 2 (Namespace A) Process 3 (Namespace B) Kernel Container Host OS Kernel VM (Type-1) Guest OS Kernel Kernel hypervisor コンテナ上からノードに権限昇格されてしまうと、別のコンテナを侵害されてしまう
15 Managed by GCP API Server Node Kubelet kube-proxy Admin/ Developer GCE Metadata Kubernetes API Pod A Pod B Pod C PodからNodeレベルの クレデンシャルにアクセス可能 開発者は最小限の権限 のみ所有すべき Pod A Pod B Pod C Network制限なし 高権限Podを作成可能 ※NodeからはコンテナのSecretを読み取れる Kubernetes is not secure by default GCP固有
16 ● 一番防ぎたいシナリオ ○ 攻撃者によるコンテナへの侵入 -> Nodeへの権限昇格 ■ NodeからはNode上の全コンテナのSecretを取得できる 1. 開発者の端末経由 (内部から) 主な攻撃シナリオ Privileged Container Node 盗難/マルウェア感染 K8S API Privileged Container作成 権限昇格 2. コンテナ上のアプリケーション脆弱性 (外部から) Node *コンテナ上の情報閲覧可能 Pod A Pod B Pod C Application on Pod Node 権限昇格 Exploit The Internet 情報窃取 情報窃取
17 MITRE ATT&CK for Kubernetes Microsoft “Secure containerized environments with updated threat matrix for Kubernetes” ● 攻撃のTTPs(Tactics, Techniques and Procedures)
40 References ● Mercari’s presentation and blogs ○ Kubernetes Security for Microservices ○ Scaling Kubernetes Tenant Management with Hierarchical Namespaces Controller ○ Enhance Kubernetes Security with OPA Gatekeeper ● Taichi Nakashima “Zero Touch Productionとは何か” ● Heather Adkins, Betsy Beyer, Paul Blankinship, Ana Oprea, Piotr Lewandowski, Adam Stubblefield “Building Secure & Reliable Systems” ● Michał Czapiński, Rainer Wolafka “Zero Touch Prod: Towards Safer and More Secure Production Environments” ● Maya Kaczorowski, Ann Wallace”Container Forensics: What to Do When Your Cluster is a Cluster” ● Liz Rice “Container Security” ● Microsoft “Secure containerized environments with updated threat matrix for Kubernetes” ● Special Thanks: @keke, @deeeet