

# 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/securityhub-standards-fsbp.html) 的服務可簡化在 AWS Organizations 間部署控制和防護機制的作業，以識別和修正公開暴露的資源。例如，AWS Control Tower 具備受管的防護機制，可偵測是否有任何[可由 AWS 帳戶 還原的 Amazon EBS 快照](https://docs.aws.amazon.com/controltower/latest/userguide/what-is-control-tower.html)。 

 **實作步驟** 
+  **考慮[為 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 會檢查具有公開存取許可的 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)

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