

# SEC03-BP07 分析公有和跨帳戶存取權
<a name="sec_permissions_analyze_cross_account"></a>

持續監控強調公有和跨帳戶存取權的調查結果。減少僅對需要此存取之特定資源的公有存取權和跨帳戶存取權。

 **預期成果：**知道您共用了哪些 AWS 資源以及共用的對象。持續監控和稽核您共用的資源以確認這些資源僅與已授權主體共用。

 **常見的反模式：**
+  沒有維持共用資源的詳細目錄。
+  未遵循程序來核准跨帳戶或資源的公有存取權。

 **未建立此最佳實務時的曝險等級：**低 

## 實作指引
<a name="implementation-guidance"></a>

 如果您的帳戶位於 AWS Organizations 中，您可以將資源的存取權授予整個組織、特定組織單位或個別帳戶。如果您的帳戶不是組織的成員，您可以與個別帳戶共用資源。您可以使用以資源為基礎的政策 (例如 [Amazon Simple Storage Service (Amazon S3) 儲存貯體政策](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)) 來授予直接跨帳戶存取權，或允許另一個帳戶中的主體擔任您帳戶中的 IAM 角色。當使用資源政策時，確認僅將該存取權授予已授權的主體。定義程序，來核准所有需要公開提供的資源。

 [AWS Identity and Access Management Access Analyzer](https://aws.amazon.com/iam/features/analyze-access/) 採用[可證明的安全性](https://aws.amazon.com/security/provable-security/)來識別從其帳戶外部存取資源的所有路徑。它會持續審查資源政策，並報告公有和跨帳戶存取權的調查結果，讓您輕鬆分析潛在的各種存取。考慮使用 AWS Organizations 設定 IAM Access Analyzer，以確認您對所有帳戶具有可見性。IAM Access Analyzer 也允許您在部署資源許可之前[預覽調查結果](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-access-preview.html)。這可讓您驗證政策變更是否僅授予對您資源的預期公有和跨帳戶存取權。設計多帳戶存取權時，您可以使用[信任政策](https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/)來控制可以擔任角色的情況。例如，您可以使用 [`PrincipalOrgId` 條件金鑰來拒絕嘗試從 AWS Organizations](https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/) 外部擔任角色的動作。

 [AWS Config 可以報告設定不當的資源](https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-Publicly-Accessible-Resources.html)，並可透過 AWS Config 政策檢查來偵測已設定公開存取的資源。諸如 [AWS Control Tower](https://aws.amazon.com/controltower/) 和 [AWS Security Hub CSPM](https://docs.aws.amazon.com/securityhub/latest/userguide/what-is-securityhub.html) 的服務可簡化在 AWS Organizations 間部署控制和防護機制的作業，以識別和修正公開暴露的資源。例如，AWS Control Tower 具備受管的防護機制，可偵測是否有任何[可由 AWS 帳戶 還原的 Amazon EBS 快照](https://docs.aws.amazon.com/controltower/latest/userguide/what-is-control-tower.html)。

### 實作步驟
<a name="implementation-steps"></a>
+  **考慮[對 AWS Organizations 使用 AWS Config](https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-config.html)：** AWS Config 可讓您將 AWS Organizations 內來自多個帳戶的調查結果彙總到一個委派的管理員帳戶。這提供了全面性檢視，並讓您[在帳戶間部署 AWS Config 規則 以偵測公開可存取的資源](https://docs.aws.amazon.com/config/latest/developerguide/config-rule-multi-account-deployment.html)。
+  **設定 AWS Identity and Access Management Access Analyzer：**IAM Access Analyzer 可協助您識別組織及帳戶中[與外部實體共用](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-getting-started.html)的資源，例如 Amazon S3 儲存貯體或 IAM 角色。
+  **使用 AWS Config 中的自動修復以回應 Amazon S3 儲存貯體的公開存取設定中的變更：**[您可以自動開啟 Amazon S3 儲存貯體的封鎖公開存取設定](https://aws.amazon.com/blogs/security/how-to-use-aws-config-to-monitor-for-and-respond-to-amazon-s3-buckets-allowing-public-access/)。
+  **實作監控和提醒以識別 Amazon S3 儲存貯體是否已變為公有：**您必須設立[監控和提醒](https://aws.amazon.com/blogs/aws/amazon-s3-update-cloudtrail-integration/)以識別何時關閉 Amazon S3 封鎖公開存取，以及 Amazon S3 儲存貯體是否變為公有。此外，如果您正在使用 AWS Organizations，可以建立[服務控制政策](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html)來防止對 Amazon S3 公開存取政策進行變更。[AWS Trusted Advisor](https://docs.aws.amazon.com/awssupport/latest/user/trusted-advisor.html) 會檢查具有公開存取許可的 Amazon S3 儲存貯體。將上傳或刪除存取權授予每個人的儲存貯體許可，可讓任何人在儲存貯體中新增、修改或移除項目，進而產生潛在的安全問題。Trusted Advisor 檢查會分析明確的儲存貯體許可，以及可能覆寫儲存貯體許可的關聯儲存貯體政策。您也可以使用 AWS Config 來監控 Amazon S3 儲存貯體的公開存取。如需詳細資訊，請參閱[如何使用 AWS Config 來監控及回應允許公開存取的 Amazon S3 儲存貯體](https://aws.amazon.com/blogs/security/how-to-use-aws-config-to-monitor-for-and-respond-to-amazon-s3-buckets-allowing-public-access/)。

 檢閱 Amazon S3 儲存貯體的存取控制時，請務必考量儲存於其中的資料性質。[Amazon Macie](https://docs.aws.amazon.com/macie/latest/user/findings-types.html) 是一項服務，其設計在於協助您探索和保護敏感資料，例如個人身分識別資訊 (PII)、受保護健康資訊 (PHI)，以及私有金鑰或 AWS 存取金鑰等憑證。

## 資源
<a name="resources"></a>

 **相關文件：**
+  [使用 AWS Identity and Access Management Access Analyzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html?ref=wellarchitected)
+ [AWS Control Tower 控制程式庫](https://docs.aws.amazon.com/controltower/latest/userguide/controls-reference.html)
+  [AWS 基礎安全最佳實務標準](https://docs.aws.amazon.com/securityhub/latest/userguide/securityhub-standards-fsbp.html)
+  [AWS Config 受管規則](https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_use-managed-rules.html) 
+  [AWS Trusted Advisor 檢查參考](https://docs.aws.amazon.com/awssupport/latest/user/trusted-advisor-check-reference.html) 
+ [ 使用 Amazon EventBridge 監控 AWS Trusted Advisor 檢查結果](https://docs.aws.amazon.com/awssupport/latest/user/cloudwatch-events-ta.html)
+ [ 管理組織內所有帳戶間的 AWS Config 規則](https://docs.aws.amazon.com/config/latest/developerguide/config-rule-multi-account-deployment.html)
+ [AWS Config 和 AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/services-that-can-integrate-config.html)
+ [在 Amazon EC2 中公開提供您的 AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sharingamis-intro.html#block-public-access-to-amis)

 **相關影片：**
+ [保護多帳戶環境的最佳實務](https://www.youtube.com/watch?v=ip5sn3z5FNg)
+ [深入了解 IAM Access Analyzer](https://www.youtube.com/watch?v=i5apYXya2m0)