Slide 1

Slide 1 text

閉域要件におけるEC2のアクセス制御 ~SaaS・Private Link の罠と Network Firewall の活用~ 2022.5.30 Security-JAWS 第25回 Copyright (c) Mizuho Research & Technologies, Ltd. All Rights Reserved. (免責事項) 当資料は情報提供のみを目的として作成されたものであり、商品の勧誘を目的としたものではありません。 本資料は、当社が信頼できると判断した各種データに基づき作成されておりますが、その正確性、確実性を 保証するものではありません。また、本資料に記載された内容は予告なしに変更されることもあります。

Slide 2

Slide 2 text

自己紹介  氏名:松尾 優成(まつお ゆうせい)  所属:みずほ RT 先端技術研究部 兼 プロジェクト推進部  役割:  AWS社内案件の設計・構築サポート  みずほグループ横断コミュニティ ”コクリエ” の運営

Slide 3

Slide 3 text

みずほのAWS利用状況  重要情報を扱うシステムの場合、閉域網とすることが主流  AWS と自社設備のハイブリッド・クラウド構成となることが多い  ベストプラクティスに沿って、マルチアカウント構成が主流

Slide 4

Slide 4 text

前回は、閉域構成での S3 関連ポリシーを紹介 #secjaws23

Slide 5

Slide 5 text

本日話すこと  SaaS・Private Link の罠と Network Firewall の活用  閉域構成での EC2 アクセス制御(Session Manager 利用)  IAM ポリシー  IAM ロールの信頼ポリシー  VPC エンドポイントポリシー

Slide 6

Slide 6 text

本日話すこと(前半戦)  SaaS・Private Link の罠と Network Firewall の活用  閉域構成でのEC2アクセス制御(Session Manager利用)  IAMロールの信頼ポリシー  VPCエンドポイントポリシー  IAMポリシー

Slide 7

Slide 7 text

AWS Network Firewall とは・・・  URL フィルタリングなど N/W 保護の 機能をもつマネージドサービス  専用の Firewall Endpoint を サブネットに設置して利用  柔軟にルールを設定でき、 様々な通信を監査可能 https://aws.amazon.com/jp/blogs/news/networking-and- content-delivery-deployment-models-for-aws-network-firewall/

Slide 8

Slide 8 text

Network Firewall を活用した 構成例を紹介

Slide 9

Slide 9 text

構成概要 VPC Corporate data center ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway SaaS Manager Server Security Patches Rule Allowed URLs Direct Connect Anti-virus Agent

Slide 10

Slide 10 text

構成概要 VPC Corporate data center ENI EC2 VPC Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway SaaS Manager Server Security Patches Rule Allowed URLs Anti-virus Agent  オンプレミスから渡された機微情報を EC2 で分析して還元するシステム (インターネットからのインバウンドアクセスなし) Direct Connect Transit Gateway

Slide 11

Slide 11 text

構成概要  EC2 にウィルス対策ソフトのエージェントを導入。  エージェントは定義ファイルの更新など、マネージャーサーバーとの通信が必須。 VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect

Slide 12

Slide 12 text

構成概要  エージェントは Firewall Endpoint を経由して、 インターネット上のマネージャーサーバーと通信。 VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Anti-virus Agent

Slide 13

Slide 13 text

構成概要  ステートフルドメインリストフィルタで、宛先ドメインを制限。  リストにないドメインに対しては、アクセス拒否。(ホワイトリスト形式) VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway SaaS Manager Server Security Patches Rule Allowed URLs Anti-virus Agent Corporate data center Direct Connect

Slide 14

Slide 14 text

Network Firewall に 辿り着いた経緯を振り返る

Slide 15

Slide 15 text

当初想定していた構成 ※オンプレ部分は割愛 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone

Slide 16

Slide 16 text

当初想定していた構成 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone  マネージャーサーバーとの閉域接続を実現するため、Private Link を利用。

Slide 17

Slide 17 text

当初想定していた構成 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone  マネージャーサーバーとの通信用に、バージニア北部リージョンで サービス側が VPC エンドポイントを提供。

Slide 18

Slide 18 text

当初想定していた構成 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone  本来は国内リージョンのみを利用したかったものの、 SaaS Private Linkの制約により、やむなく海外リージョンも利用。

Slide 19

Slide 19 text

当初想定していた構成 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone  リージョン間接続は、VPC Peering を採用。

Slide 20

Slide 20 text

当初想定していた構成 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone  Transit Gateway のクロスリージョン接続も検討したものの、 僅かにコストが嵩むため、 断念。(ペストプラクティスでない実感はあった・・・)

Slide 21

Slide 21 text

当初想定していた構成 VPC SaaS VPCe EC2 VPC Transit Gateway SaaS Manager Server VPC VPC Anti-virus Agent PrivateLink North Virginia Region Tokyo Region VPC Peering Private Hosted zone  上記構成で検証し、問題なく利用できることを確認!

Slide 22

Slide 22 text

時は流れ、半年後・・・ 構築フェーズが終わっているはずの時期だった

Slide 23

Slide 23 text

Private Link 経由で ウィルス対策ソフト を利用できなくなった・・・

Slide 24

Slide 24 text

SaaS の仕様変更が発生していた  マネージャーサーバーのエンドポイント URL が変更。  新 URL は Private Link に未対応※で、インターネット経路が必須。 検証済みと油断していたため、気づくのが遅れた・・・ ※2021年4月時点 SaaS Manager Server PrivateLink 旧 URL 新 URL Internet Gateway 必須!

Slide 25

Slide 25 text

マネージャーサーバーを自前でホストするには 遅すぎたため、代替案を模索・・・ プロキシサーバーを 置きたくないし、 マネージドサービス 使いたい…

Slide 26

Slide 26 text

そんな中、こんなアップデートが・・・

Slide 27

Slide 27 text

https://aws.amazon.com/jp/about-aws/whats-new/2021/03/

Slide 28

Slide 28 text

https://aws.amazon.com/jp/about-aws/whats-new/2021/03/ Network Firewall で解決できそう! (ついでに東京リージョンへ集約できるかも…?)

Slide 29

Slide 29 text

DevelopersIO や aws-samples を 参考にさせていただき、素早く検証・構築! (当時は Blackbelt の公開前だった)

Slide 30

Slide 30 text

構成概要(再掲) 無事に構築できました! VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect

Slide 31

Slide 31 text

構成概要(再掲) 無事に構築できました! VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs 構成変更について、 担当者が良い感じに 社内説明してくれました! Corporate data center Direct Connect

Slide 32

Slide 32 text

Network Firewall を導入して 嬉しかった点を紹介!

Slide 33

Slide 33 text

Network Firewall 導入の嬉しい点① 基本構成が東京リージョンのみで完結した!※バックアップのみ大阪を利用 VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Tokyo Region Corporate data center Direct Connect

Slide 34

Slide 34 text

Network Firewall 導入の嬉しい点② アウトバウンドが集約され、ハブ & スポーク型の N/W 構成になった! VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Tokyo Region Corporate data center Direct Connect

Slide 35

Slide 35 text

Network Firewall 導入の嬉しい点③ 運用課題だった閉域要件の OS パッチ適用が、楽になった! VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Tokyo Region Corporate data center Direct Connect

Slide 36

Slide 36 text

悩んだこと・・・ AWS 宛の VPC エンドポイントも一部廃止して Network Firewall 経由にしておけば良かった? VPC VPCe (I/F型) EC2 com.amazonaws.ap-northeast-1.ec2, com.amazonaws.ap-northeast-1.ssm, etc...

Slide 37

Slide 37 text

AWS API のアクセスも Network Firewall 経由? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region VPCe ? ? ? ? Corporate data center Direct Connect

Slide 38

Slide 38 text

AWS API のアクセスも Network Firewall 経由? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region VPCe ? ? ? ? Corporate data center Direct Connect S3 など通信量が大きくなる場合は VPCe 経由がお得

Slide 39

Slide 39 text

AWS API のアクセスも Network Firewall 経由? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region VPCe ? ? ? ? Corporate data center Direct Connect 通信量が少なければ Network Firewall 経由にする?

Slide 40

Slide 40 text

AWS API のアクセスも Network Firewall 経由? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region VPCe ? ? ? ? { "Effect": "Deny", "Principal": {"AWS": "*"}, "Action": "*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "アカウントA-ID" } } }, { "Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*" } #secjaws23 VPCe ポリシー例 Corporate data center Direct Connect

Slide 41

Slide 41 text

AWS API のアクセスも Network Firewall 経由? VPC エンドポイントポリシーでアクセス先 AWS アカウントを制限 VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region VPCe ? ? ? ? { "Effect": "Deny", "Principal": {"AWS": "*"}, "Action": "*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "アカウントA-ID" } } }, { "Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*" } #secjaws23 VPCe ポリシー例 Corporate data center Direct Connect 利用アカウントを自社アカウントのみに制限

Slide 42

Slide 42 text

AWS API のアクセスも Network Firewall 経由? 社外クレデンシャルを持ち込まれた場合、 社外アカウントへのデータ流出リスクあり VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region 社外アカウント 流出! 社外 Credential Corporate data center Direct Connect Firehose

Slide 43

Slide 43 text

AWS API のアクセスも Network Firewall 経由? クレデンシャル持ち込みの防止手段として VPC エンドポイントの利用を継続 VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent Rule Allowed URLs Tokyo Region VPCe Keep Corporate data center Direct Connect AWSサービスの 宛先は未許可

Slide 44

Slide 44 text

本日話すこと(後半戦)  SaaS・Private Link の罠と Network Firewall の活用Network  閉域構成での EC2 アクセス制御(Session Manager 利用)  IAM ポリシー  IAM ロールの信頼ポリシー  VPC エンドポイントポリシー

Slide 45

Slide 45 text

SaaS 利用の問題が解消し、一件落着! と思われたが・・・

Slide 46

Slide 46 text

社内で新規導入予定の CloudHub で 予期せぬ事態が発生した ※CloudHub・・・マルチクラウドの閉域接続サービス (CloudHub はサードパーティで、AWS サービスとは別) VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Cloud Hub

Slide 47

Slide 47 text

開発者 社内 N/W 担当者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。

Slide 48

Slide 48 text

開発者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。 https://d1.awsstatic.com/webinars/jp/pdf/services/ 20210209-AWS-Blackbelt-DirectConnect.pdf 社内 N/W 担当者

Slide 49

Slide 49 text

開発者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。 Transit VIF は単一であり、 個別案件に払い出せません! 社内 N/W 担当者

Slide 50

Slide 50 text

開発者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。 Transit VIF は単一であり、 個別案件に払い出せません! https://d1.awsstatic.com/webinars/jp/pdf/services/ 20210209-AWS-Blackbelt-DirectConnect.pdf 社内 N/W 担当者

Slide 51

Slide 51 text

開発者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。 Transit VIF は単一であり、 個別案件に払い出せません! ST 直前で急いでいるのですが・・・ なんとかなりませんか?? 社内 N/W 担当者

Slide 52

Slide 52 text

開発者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。 Transit VIF は単一であり、 個別案件に払い出せません! 残念ですが、新規の社内共通基盤に VIF を払い出す予定ですので・・・ ST 直前で急いでいるのですが・・・ なんとかなりませんか?? 社内 N/W 担当者

Slide 53

Slide 53 text

開発者 Direct Connect と Transit G/W の接続用に Transit VIF の提供をお願いします。 Transit VIF は単一であり、 個別案件に払い出せません! 残念ですが、新規の社内共通基盤に VIF を払い出す予定ですので・・・ えっと・・・(詰んだ?) ST 直前で急いでいるのですが・・・ なんとかなりませんか?? 社内 N/W 担当者

Slide 54

Slide 54 text

Direct Connect Gatewayと Transit Gatewayが接続できないため、代替案を模索 VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Cloud Hub

Slide 55

Slide 55 text

【代替案①】 VPC を挟む? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Cloud Hub VPC 直接経路伝播できず、 EC2・NLBなどが必要

Slide 56

Slide 56 text

VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Cloud Hub VPC 直接経路伝播できず、 EC2・NLBなどが必要 運用負担になる踏み台リソースを置きたくなかったので、不採用 【代替案①】 VPC を挟む?

Slide 57

Slide 57 text

【代替案②】 Direct Connect GW を各 VPC に繋ぐ? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Cloud Hub VGW 各 VPC では VGW の追加・ ルート変更が必要

Slide 58

Slide 58 text

【代替案②】 Direct Connect GW を各 VPC に繋ぐ? VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate data center Direct Connect Cloud Hub 各 VPC では VGW の追加・ ルート変更が必要 VGW ネットワーク変更が大きく、ハブ & スポーク型でなくなるため、不採用

Slide 59

Slide 59 text

試行錯誤した結果・・・

Slide 60

Slide 60 text

Session Manager 案を採用! VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate Cloud Hub VPC VPCe Session Manager 閉域用 Direct Connect ネットワーク変更が少なく 踏み台リソースも不要!

Slide 61

Slide 61 text

詳細な図を用いて Session Manager での閉域構成を紹介

Slide 62

Slide 62 text

アカウント A Session Manager の利用イメージ VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role

Slide 63

Slide 63 text

アカウント A Session Manager の利用イメージ ① 運用者が閉域端末から、アクセス先アカウントの IAM ロール「ssm-role」を引き受け VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI aws sts assume-role --role-arn “arn:aws:iam::[アカウントB]:role/ssm-role” … ssm-role

Slide 64

Slide 64 text

アカウント A Session Manager の利用イメージ ② 閉域端末で引き受けたロールのクレデンシャルを使い、ポートフォワーディングを実行 VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI aws ssm start-session --document-name AWS-StartPortForwardingSession --target [instance-id] --parameters portNumber=“22",localPortNumber=“10022"… ssm-role

Slide 65

Slide 65 text

アカウント A Session Manager 閉域利用の注意点① VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role VPC エンドポイント ・ssm ・ssmmessages ・ec2messages ・ ...

Slide 66

Slide 66 text

アカウント A Session Manager 閉域利用の注意点① VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role VPC エンドポイント ・ssm ・ssmmessages ・ec2messages ・ ... VPC エンドポイント ・ssm ・ssmmessages ・(ec2messages) ・sts ... リクエスト元にも 複数の VPCe が必要!→

Slide 67

Slide 67 text

アカウント A Session Manager 閉域利用の注意点② VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Network ACL を制御している場合、 Port 443 のインバウンドアクセス開放が必要 (Security Group の Port 22 は開放不要)

Slide 68

Slide 68 text

疑問・・・ Session Manager の 閉域利用は本当に安全?

Slide 69

Slide 69 text

アカウント A Session Manager では、きちんと対策しないと・・・ VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role

Slide 70

Slide 70 text

アカウント A Session Manager では、きちんと対策しないと・・・ VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI アカウントC(社外) 流出! C データ流出リスクがある!→ EC2 VPC Session Manager VPCe STS C ssm-role

Slide 71

Slide 71 text

アカウント A Session Manager では、きちんと対策しないと・・・(その②) VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role

Slide 72

Slide 72 text

アカウント A Session Manager では、きちんと対策しないと・・・(その②) VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI 社外からのアクセスリスクがある!→ ssm-role

Slide 73

Slide 73 text

どのようにポリシーを組み合わせて Session Manager の利用を閉域に制限する?

Slide 74

Slide 74 text

アカウント A Session Manager の利用で着目するポリシーは 4 つ VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅰ Ⅳ Ⅲ Ⅰ. アクセスキーの IAMポリシー Ⅱ. VPC エンドポイント ポリシー Ⅲ. IAM ロールの 信頼ポリシー Ⅳ. IAM ロールの IAM ポリシー Ⅱ ssm-role

Slide 75

Slide 75 text

アカウント A Ⅰ. アクセスキーの IAM ポリシー ※実態は、IAM グループに紐づくポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅰ ssm-role

Slide 76

Slide 76 text

アカウント A Ⅰ. アクセスキーの IAM ポリシー ※実態は、IAM グループに紐づくポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅰ ssm-role { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::${AccountB-ID}:role/ssm-role" }

Slide 77

Slide 77 text

アカウント A Ⅰ. アクセスキーの IAM ポリシー ※実態は、IAM グループに紐づくポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅰ { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::${AccountB-ID}:role/ssm-role" } ssm-role スイッチ先を自社内に制限する ため、最小権限を設定! (キー漏えい時の影響も抑えたい)

Slide 78

Slide 78 text

アカウント A Ⅱ. VPC エンドポイントポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅱ ssm-role

Slide 79

Slide 79 text

アカウント A Ⅱ. VPC エンドポイントポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅱ ssm-role { "Effect": "Deny", "Principal": {"AWS": "*"}, "Action": "*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "AccountIDs" } } }, { "Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*" }

Slide 80

Slide 80 text

アカウント A Ⅱ. VPC エンドポイントポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅱ ssm-role { "Effect": "Deny", "Principal": {"AWS": "*"}, "Action": "*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "AccountIDs" } } }, { "Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*" } アカウントC (社外) C C 社外アカウントのクレデンシャルを持ち込み、 社外 EC2 へのアクセスを試みる EC2

Slide 81

Slide 81 text

アカウント A Ⅱ. VPC エンドポイントポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅱ ssm-role { "Effect": "Deny", "Principal": {"AWS": "*"}, "Action": "*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "AccountIDs" } } }, { "Effect": "Allow", "Principal": "*", "Action": "*", "Resource": "*" } aws:PrincipalAccount で クレデンシャル持ち込みを禁止! C アカウントC (社外) C EC2

Slide 82

Slide 82 text

アカウント A Ⅲ. IAM ロールの信頼ポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅲ

Slide 83

Slide 83 text

アカウント A Ⅲ. IAM ロールの信頼ポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅲ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::${UserAccount}:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceVPCe": "${STS-VPCe-ID}" }, "Bool": { "aws:MultiFactorAuthPresent": "true" }, "StringLike": { "sts:RoleSessionName": "${aws:username}" } } }

Slide 84

Slide 84 text

アカウント A Ⅲ. IAM ロールの信頼ポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅲ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::${UserAccount}:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceVPCe": "${STS-VPCe-ID}" }, "Bool": { "aws:MultiFactorAuthPresent": "true" }, "StringLike": { "sts:RoleSessionName": "${aws:username}" } } } 流出したアクセスキー 社外から スイッチロールを試みる

Slide 85

Slide 85 text

アカウント A Ⅲ. IAM ロールの信頼ポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅲ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::${UserAccount}:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceVPCe": "${STS-VPCe-ID}" }, "Bool": { "aws:MultiFactorAuthPresent": "true" }, "StringLike": { "sts:RoleSessionName": "${aws:username}" } } } aws:SourceVPCe で 社外からのスイッチロールを禁止! 流出したアクセスキー

Slide 86

Slide 86 text

アカウント A Ⅲ. IAM ロールの信頼ポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅲ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::${UserAccount}:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceVPCe": "${STS-VPCe-ID}" }, "Bool": { "aws:MultiFactorAuthPresent": "true" }, "StringLike": { "sts:RoleSessionName": "${aws:username}" } } } ← MFA を強制

Slide 87

Slide 87 text

アカウント A Ⅲ. IAM ロールの信頼ポリシー VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅲ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::${UserAccount}:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceVPCe": "${STS-VPCe-ID}" }, "Bool": { "aws:MultiFactorAuthPresent": "true" }, "StringLike": { "sts:RoleSessionName": "${aws:username}" } } } ← CloudTrail でロール使用者を追跡するため STS のセッション名を IAM ユーザー名と 一致させるように強制

Slide 88

Slide 88 text

アカウント A Ⅳ. IAM ロールの IAM ポリシー(スイッチロール後の話) VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅳ

Slide 89

Slide 89 text

アカウント A Ⅳ. IAM ロールの IAM ポリシー(スイッチロール後の話) VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅳ { "Effect": "Allow", "Action": "ssm:StartSession", "Resource": [ "arn:aws:ec2:${Region}:${AccountId}:instance/*", "arn:aws:ssm:::document/AWS-StartPortForwardingSession" ], "Condition": { "BoolIfExists": { "ssm:SessionDocumentAccessCheck": "true" }, "StringEquals": { "aws:SourceVPCe": "${SSM-VPCe-ID}" } } }, …

Slide 90

Slide 90 text

アカウント A Ⅳ. IAM ロールの IAM ポリシー(スイッチロール後の話) VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅳ { "Effect": "Allow", "Action": "ssm:StartSession", "Resource": [ "arn:aws:ec2:${Region}:${AccountId}:instance/*", "arn:aws:ssm:::document/AWS-StartPortForwardingSession" ], "Condition": { "BoolIfExists": { "ssm:SessionDocumentAccessCheck": "true" }, "StringEquals": { "aws:SourceVPCe": "${SSM-VPCe-ID}" } } }, … 流出した ssm-role の 一時クレデンシャル (スイッチロール後) 社外から Session Manager 経由で EC2 へ侵入を試みる

Slide 91

Slide 91 text

アカウント A Ⅳ. IAM ロールの IAM ポリシー(スイッチロール後の話) VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI ssm-role Ⅳ { "Effect": "Allow", "Action": "ssm:StartSession", "Resource": [ "arn:aws:ec2:${Region}:${AccountId}:instance/*", "arn:aws:ssm:::document/AWS-StartPortForwardingSession" ], "Condition": { "BoolIfExists": { "ssm:SessionDocumentAccessCheck": "true" }, "StringEquals": { "aws:SourceVPCe": "${SSM-VPCe-ID}" } } }, … aws:SourceVPCe で 社外からの Session Manager を禁止! 流出した ssm-role の 一時クレデンシャル (スイッチロール後)

Slide 92

Slide 92 text

アカウント A ポリシー関連をまとめてみる VPC Corporate data center Direct Connect VPCe 閉域用 EC2 運用者 Cloud Hub Direct Connect Gateway VPC アカウント B Session Manager VPCe Transit Gateway ENI Ⅰ Ⅳ Ⅲ Ⅰ. アクセスキーの IAMポリシー: 最小権限に制限 (スイッチ先を絞る) Ⅱ. VPC エンドポイント ポリシー: aws:PrincipalAccount で クレデンシャルの持込を Deny Ⅲ. IAM ロールの信頼ポリシー Ⅳ. IAMポリシー: aws:sourceVpce (sts, ssm)で 社外からのアクセスを Deny Ⅱ ssm-role

Slide 93

Slide 93 text

ちなみに・・・ 本アプローチは「データ境界」と呼ばれる ガードレール かもしれない

Slide 94

Slide 94 text

#secjaws23 の発表翌日 Security Roadshow の 大トリセッションにて →

Slide 95

Slide 95 text

#secjaws23 の発表翌日 Security Roadshow の 大トリセッションにて → あまりにも嬉しいお言葉に驚き 急いで確認しました!

Slide 96

Slide 96 text

オンデマンド配信で「データ境界」を知る AWS 環境で重要データを保護するセキュリティモデル:データ境界 (Data Perimeter) を学ぶ https://www.awssecevents.com/ja/ondemandtracks/tech_track_5/

Slide 97

Slide 97 text

オンデマンド配信で「データ境界」を知る AWS 環境で重要データを保護するセキュリティモデル:データ境界 (Data Perimeter) を学ぶ https://www.awssecevents.com/ja/ondemandtracks/tech_track_5/ 今回のポリシー設計も データ境界のはず・・・?

Slide 98

Slide 98 text

(再掲!)Network Firewall 導入しました VPC ENI EC2 VPC Transit Gateway Direct Connect Gateway ENI Network Firewall NAT Gateway Firewall Endpoint Internet Gateway Anti-virus Agent SaaS Manager Server Security Patches Rule Allowed URLs Corporate Cloud Hub VPC VPCe Session Manager 閉域用 Direct Connect

Slide 99

Slide 99 text

まとめ  プロジェクトリスクとして、SaaS の仕様変更を想定しよう  Network Firewall と VPCe の併用で緻密なアウトバウンド制御可  閉域で Session Manager 利用時の注意点は・・・ • 最小権限を遵守しているか • クレデンシャルの持込を対策できているか • 社外からのアクセスを防いでいるか