

# SEC06-BP05 自动保护计算
<a name="sec_protect_compute_auto_protection"></a>

 自动执行保护计算的操作，减少人工干预的需要。使用自动扫描检测计算资源中是否可能存在问题，并通过自动程序化响应或实例集管理操作进行修复。 在您的 CI/CD 流程中融入自动化功能，以最新的依赖项来部署值得信赖的工作负载。

 **期望结果：**由自动化系统对计算资源进行所有扫描和修补。您可以使用自动验证来检查软件映像和依赖项是否来自可信来源，以及是否被篡改。自动检查工作负载是否有最新的依赖项，并对工作负载进行签名，以便在 AWS 计算环境中建立信任。 一旦检测到不合规的资源，就会启动自动修复措施。  

 **常见反模式：**
+  遵循不可变基础设施的做法，但没有制定紧急修补或更换生产系统的解决方案。
+  使用自动化技术来修复配置错误的资源，但没有手动覆盖机制。 在某些情况下，您可能需要调整要求，并且在进行这些更改之前需要暂停自动化操作。

 **建立此最佳实践的好处：**自动化操作可以降低未经授权访问和使用计算资源的风险。 这有助于防止错误配置对生产环境产生影响，检测错误配置，并在发生错误配置时对其进行修复。 自动化操作还有助于检测未经授权的访问和使用计算资源的情况，从而缩短响应时间。 这反过来又能够缩小问题的总体影响范围。

 **在未建立这种最佳实践的情况下暴露的风险等级：**中 

## 实施指导
<a name="implementation-guidance"></a>

 您可以应用安全性支柱实践中描述的自动化操作来保护计算资源。[SEC06-BP01 执行漏洞管理](https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_protect_compute_vulnerability_management.html)描述了如何在 CI/CD 管道中使用 [Amazon Inspector](https://aws.amazon.com/inspector/)，以及如何持续扫描运行时环境，查看是否存在已知的通用漏洞披露（CVE，Common Vulnerabilities and Exposures）。 您可以遵循自动化运行手册，使用 [AWS Systems Manager](https://aws.amazon.com/systems-manager/) 来应用补丁或者利用新映像重新部署，从而始终使用最新的软件和库来更新计算实例集。 使用这些技术可减少对人工流程和交互式访问计算资源的需求。 请参阅《[SEC06-BP03 减少人工管理工作和交互式访问](https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_protect_compute_reduce_manual_management.html)》，了解更多信息。

 自动化操作在部署值得信赖的工作负载方面也发挥着作用，如《[SEC06-BP02 从强化映像预置计算](https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_protect_compute_hardened_images.html)》和《[SEC06-BP04 验证软件完整性](https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_protect_compute_validate_software_integrity.html)》中所述。 您可以使用 [EC2 Image Builder](https://aws.amazon.com/image-builder/)、[AWS Signer](https://docs.aws.amazon.com/signer/latest/developerguide/Welcome.html)、[AWS CodeArtifact](https://aws.amazon.com/codeartifact/) 和 [Amazon Elastic Container Registry（ECR）](https://aws.amazon.com/ecr/)等服务，来下载、验证、构造和存储经过强化和批准的映像和代码依赖项。  通过与 Inspector 配合使用，这些服务都可以在您的 CI/CD 流程中发挥作用，这样您的工作负载只有在确认其依赖项是最新的且来自可信来源时，才会进入生产阶段。 工作负载还经过签名，这样 [AWS Lambda](https://aws.amazon.com/lambda/) 和 [Amazon Elastic Kubernetes Service（EKS）](https://aws.amazon.com/eks/)等 AWS 计算环境就能在允许工作负载运行之前，验证工作负载是否未被篡改。

 除了这些预防性控制措施之外，您还可以在计算资源的检测性控制中运用自动化。 例如，[AWS Security Hub CSPM](https://aws.amazon.com/security-hub/) 提供 [NIST 800-53 Rev. 5](https://docs.aws.amazon.com/securityhub/latest/userguide/nist-standard.html) 标准，其中包括 [[EC2.8] EC2 实例应使用实例元数据服务版本 2（IMDSv2）](https://docs.aws.amazon.com/securityhub/latest/userguide/ec2-controls.html#ec2-8)等检查内容。 IMDSv2 使用会话验证、阻止包含 X-Forwarded-For HTTP 标头的请求，以及设置网络 TTL 为 1 等技术，来阻止来自外部来源的流量检索有关 EC2 实例的信息。Security Hub CSPM 中的这项检查可检测 EC2 实例何时使用 IMDSv1 并启动自动修复措施。参阅《[SEC04-BP04 启动对不合规资源的修复](https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_detect_investigate_events_noncompliant_resources.html)》，了解有关自动化检测和修复的更多信息。

### 实施步骤
<a name="implementation-steps"></a>

1.  利用 [EC2 Image Builder](https://docs.aws.amazon.com/imagebuilder/latest/userguide/integ-compliance-products.html) 自动创建安全、合规且经过强化的 AMI。 您可以在基础 AWS 和 APN 合作伙伴映像中融入符合互联网安全中心（CIS，Center for Internet Security）基准或安全技术实施指南（STIG，Security Technical Implementation Guide）标准的控制措施，从而生成自己的映像。

1.  自动执行配置管理。使用配置管理服务或工具，在计算资源中自动实施和验证安全配置。  

   1.  使用 [AWS Config](https://aws.amazon.com/config/) 自动执行配置管理 

   1.  使用 [AWS Security Hub CSPM](https://aws.amazon.com/security-hub/) 自动管理安全性和合规性态势 

1.  自动修补或替换 Amazon Elastic Compute Cloud（Amazon EC2）实例。AWSSystems Manager Patch Manager 使用安全相关的更新和其它类型的更新自动执行修补托管实例的流程。您可以使用 Patch Manager 来应用操作系统和应用程序的补丁。

   1.  [AWS Systems Manager Patch Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-patch.html) 

1.  自动扫描计算资源以便查找通用漏洞披露（CVE，Common Vulnerabilities and Exposures），并在构建管道中嵌入安全扫描解决方案。

   1.  [Amazon Inspector](https://aws.amazon.com/inspector/) – 

   1.  [ECR 映像扫描](https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning.html) 

1.  考虑使用 Amazon GuardDuty 自动检测恶意软件和威胁，以便保护计算资源。在 AWS 环境中调用 [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 函数时，GuardDuty 还可以识别出潜在问题。  

   1.  [Amazon GuardDuty](https://aws.amazon.com/guardduty/) 

1.  考虑采用 AWS 合作伙伴解决方案。AWS合作伙伴提供业界领先的产品，这些产品与您的本地环境中的现有控制措施等效、相同或与之集成。这些产品对现有 AWS 服务起到补充作用，使您能够在云端和本地环境中部署全面的安全架构，进而实现无缝效果更好的体验。

   1.  [基础结构安全性](https://aws.amazon.com/security/partner-solutions/#infrastructure_security) 

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

 **相关最佳实践：**
+  [SEC01-BP06 自动部署标准安全控制措施](https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_securely_operate_automate_security_controls.html) 

 **相关文档：**
+  [Get the full benefits of IMDSv2 and disable IMDSv1 across your AWS infrastructure](https://aws.amazon.com/blogs/security/get-the-full-benefits-of-imdsv2-and-disable-imdsv1-across-your-aws-infrastructure/) 

 **相关视频：**
+  [Security best practices for the Amazon EC2 instance metadata service](https://youtu.be/2B5bhZzayjI) 