

# 检测
<a name="a-detective-controls"></a>

**Topics**
+ [SEC 4  您如何检测和调查安全事件？](w2aac19b7b9b5.md)

# SEC 4  您如何检测和调查安全事件？
<a name="w2aac19b7b9b5"></a>

通过日志和指标来记录和分析事件，以便了解信息。针对安全事件和潜在的威胁采取措施，以便保护您的工作负载。

**Topics**
+ [SEC04-BP01 配置服务和应用程序日志记录](sec_detect_investigate_events_app_service_logging.md)
+ [SEC04-BP02 集中分析日志、结果和指标](sec_detect_investigate_events_analyze_all.md)
+ [SEC04-BP03 自动响应事件](sec_detect_investigate_events_auto_response.md)
+ [SEC04-BP04 实施可操作的安全事件](sec_detect_investigate_events_actionable_events.md)

# SEC04-BP01 配置服务和应用程序日志记录
<a name="sec_detect_investigate_events_app_service_logging"></a>

 在整个工作负载中配置日志记录，包括应用程序日志、资源日志和 AWS 服务日志。例如，确保已为组织内的所有账户启用 AWS CloudTrail、Amazon CloudWatch Logs、Amazon GuardDuty 和 AWS Security Hub CSPM。 

基本做法是在账户级别建立一套检测机制。这套基本机制的目的是记录和检测对您账户中的所有资源执行的多种操作。它们允许您构建全面的检测能力和一些用于添加功能的选项，包括自动修复和合作伙伴集成。

在 AWS 中，可以实施这套基本机制的服务包括：
+ [AWS CloudTrail](http://aws.amazon.com/cloudtrail) 可提供 AWS 账户活动的事件历史记录，包括通过 AWS 管理控制台、AWS 开发工具包、命令行工具和其他 AWS 服务执行的操作。
+ [AWS Config](http://aws.amazon.com/config) 监控和记录您的 AWS 资源配置，并允许您对照所需的配置自动执行评估和修复。
+ [Amazon GuardDuty](http://aws.amazon.com/guardduty) 是一种威胁检测服务，可持续监控恶意活动和未经授权的行为，从而保护您的 AWS 账户和工作负载。
+ [AWS Security Hub CSPM](http://aws.amazon.com/security-hub) 集中聚合、组织和优先处理来自多个 AWS 服务和可选第三方产品的安全警报或调查结果，以使您全面了解安全警报和合规性状态。

在账户级别构建基础时，很多核心 AWS 服务（例如 [Amazon Virtual Private Cloud Console（Amazon VPC）](http://aws.amazon.com/vpc)提供了服务级别的日志记录功能。[Amazon VPC 流日志](https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html) 可让您捕获有关传入和传出网络接口的 IP 流量的信息，这些信息可提供对于连接历史记录的宝贵见解，并根据异常行为触发自动操作。

对于并非起源于 AWS 服务的 Amazon Elastic Compute Cloud（Amazon EC2）实例和基于应用程序的日志记录，可以使用以下工具来存储和分析日志： [Amazon CloudWatch Logs](http://aws.amazon.com/cloudwatch)。云 [代理](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_GettingStarted.html) 将从正在运行的操作系统和应用程序收集日志，并自动存储这些日志。当这些日志在 CloudWatch Logs 中可用之后，您即可 [实时处理它们](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions.html)，或者使用 [CloudWatch Logs Insights](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html)进行深入分析。

与收集和聚合日志同样重要的是，要能够从复杂的架构生成的大量日志和事件数据中提取有意义的见解。请参阅 *《可靠性支柱》白皮书* 的 [“监控”部分](https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/monitor-workload-resources.html) 以获取详细信息。日志自身可能包含敏感数据 – 当应用程序数据以错误的方式进入 CloudWatch Logs 代理捕获的日志文件中，或者为日志聚合功能配置了跨区域日志记录并且在跨境传输某些类型的信息时需要注意一些法律事项时。

一种方法是使用提供日志时在事件上触发的 AWS Lambda 函数，以筛选和编辑日志数据，然后将其转发到中央日志记录位置，例如 Amazon Simple Storage Service（Amazon S3）存储桶。未编辑的日志可以保留在本地存储桶中，直到合理的时间结束（由法律和您的法律团队决定），届时 Amazon S3 生命周期规则会自动将它们删除。可以在 Amazon S3 中使用 [Amazon S3 对象锁定](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html)功能进一步保护日志，您可在其中使用“一次写入多次读取”(WORM) 模式来存储对象。

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

## 实施指导
<a name="implementation-guidance"></a>
+  启用 AWS 服务的日志记录：启用 AWS 服务的日志记录以满足您的要求。日志记录功能包括：Amazon VPC 流日志、Elastic Load Balancing（ELB）日志、Amazon S3 存储桶日志、CloudFront 访问日志、Amazon Route 53 查询日志和 Amazon Relational Database Service（Amazon RDS）日志。
  +  [AWS Answers：原生的 AWS 安全日志记录功能 ](https://aws.amazon.com/answers/logging/aws-native-security-logging-capabilities/)
+  评估并记录特定于操作系统和应用程序的日志，以便检测可疑行为。 
  + [ 开始使用 CloudWatch Logs ](http://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_GettingStarted.html)
  + [ 开发人员工具和日志分析 ](https://aws.amazon.com/marketplace/search/results?category=4988009011)
+  对日志采取适当的控制：日志中可能包含敏感信息，只有获得授权的用户可以访问。考虑限制对 Amazon S3 存储桶和 CloudWatch Logs 日志组的访问权限。
  + [ Amazon CloudWatch 的身份验证与访问控制 ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/auth-and-access-control-cw.html)
  +  [Amazon S3 中的身份与访问管理 ](https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-access-control.html)
+  配置 [Amazon GuardDuty](https://docs.aws.amazon.com/guardduty/latest/ug/what-is-guardduty.html)：AWS 账户 是一种威胁检测服务，可持续监控恶意活动和未经授权的行为，从而保护您的 GuardDuty 和工作负载。使用实验启用 GuardDuty 并配置通过电子邮件发送的自动化警报。
+  [在 CloudTrail 中配置自定义跟踪](http://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)：配置跟踪可将日志保存比默认时长更长的时间，以便日后进行分析。
+  支持 [AWS Config](https://docs.aws.amazon.com/config/latest/developerguide/WhatIsConfig.html)：AWS Config 可以提供 AWS 账户 中的 AWS 资源配置详细信息。其中包括资源彼此之间的关系以及它们以前的配置，让您可以了解配置和关系随时间的变化。
+  支持 [AWS Security Hub CSPM](https://docs.aws.amazon.com/securityhub/latest/userguide/what-is-securityhub.html)通过 Security Hub CSPM，您可以全面了解自己在 AWS 中的安全状态，帮助您检查是否符合安全行业标准和最佳实践。Security Hub CSPM 会收集 AWS 账户、服务和支持的第三方合作伙伴产品的数据，帮助您分析您的安全趋势，并确定最高优先级的安全问题。

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

 **相关文档：** 
+ [ Amazon CloudWatch ](https://aws.amazon.com/cloudwatch/)
+  [Amazon EventBridge ](https://aws.amazon.com/eventbridge)
+ [ 开始使用：Amazon CloudWatch Logs ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_GettingStarted.html)
+  [安全合作伙伴解决方案：日志记录和监控](https://aws.amazon.com/security/partner-solutions/#logging-monitoring) 

 **相关视频：** 
+ [ 集中监控资源配置和合规性 ](https://youtu.be/kErRv4YB_T4)
+  [修正 Amazon GuardDuty 和 AWS Security Hub CSPM 调查结果 ](https://youtu.be/nyh4imv8zuk)
+ [ 云中的威胁管理：Amazon GuardDuty 和 AWS Security Hub CSPM](https://youtu.be/vhYsm5gq9jE)

 **相关示例：** 
+ [ 实验室：自动部署检测性控制 ](https://wellarchitectedlabs.com/Security/200_Automated_Deployment_of_Detective_Controls/README.html)

# SEC04-BP02 集中分析日志、结果和指标
<a name="sec_detect_investigate_events_analyze_all"></a>

 安全运营团队依靠收集日志和使用搜索工具来发现需要关注的潜在事件，这些事件可能代表未经授权的活动或无意的更改。但是，仅仅分析收集的数据和手动处理信息不足以应对从复杂架构流出的大量信息。单凭分析和报告无法及时分配合适的资源来处理事件。 

建立成熟的安全运维团队的最佳实践是，将安全事件和调查结果的流程深度集成到通知和工作流系统中，例如票证系统、错误或问题系统或者其他安全信息和事件管理（SIEM，Security Information and Event Management）系统。这样，工作流可以摆脱电子邮件和静态报告，让您能够路由、上报和管理事件或调查结果。许多组织也在逐步将安全警报集成到他们的聊天或协作以及开发人员工作效率平台中。对于正在踏上自动化之旅的组织，在规划首要自动化任务时，一个由 API 驱动的低延迟票证系统能够提供极高的灵活性。

这种最佳实践不仅适用于从描述用户活动或网络事件的日志消息生成的安全事件，还适用于在基础设施本身检测到的更改生成的安全事件。当面对一些更改，而且这些更改的不受欢迎程度足够微妙，以致于目前无法使用 AWS Identity and Access Management（IAM）和 AWS Organizations 配置的组合来防止这些更改发生时，为了保持和验证安全架构，必须能够检测更改、确定更改是否适当，然后将这些信息路由到正确的修复工作流程。

Amazon GuardDuty 和 AWS Security Hub CSPM 为日志记录提供了聚合、重复数据删除和分析机制，您也可以通过其他 AWS 服务提供这些机制。GuardDuty 可从 AWS CloudTrail 管理和数据事件、VPC DNS 日志以及 VPC 流日志等来源提取、聚合和分析信息。Security Hub CSPM 能够提取、聚合和分析来自 GuardDuty、AWS Config、Amazon Inspector、Amazon Macie、AWS Firewall Manager 以及 AWS Marketplace 中提供的大量第三方安全产品的输出，如果您相应构建了自己的代码，还将包括这些代码。GuardDuty 和 Security Hub CSPM 都有一个管理员-成员模型，此模型可以跨多个账户聚合调查结果和见解，拥有本地 SIEM 的客户通常将 Security Hub CSPM 用作 AWS 端日志和警报预处理器和聚合器，随后即可通过基于 AWS Lambda 的处理器和转发服务器提取 Amazon EventBridge。

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

## 实施指导
<a name="implementation-guidance"></a>
+  评估日志处理功能：评估用于处理日志的选项 
  +  [使用 Amazon OpenSearch Service 来记录和监控（几乎）所有内容 ](https://d1.awsstatic.com/whitepapers/whitepaper-use-amazon-elasticsearch-to-log-and-monitor-almost-everything.pdf)
  +  [寻找专门提供日志记录和监控解决方案的合作伙伴 ](https://aws.amazon.com/security/partner-solutions/#Logging_and_Monitoring)
+  作为分析 CloudTrail 日志的开始，请测试 Amazon Athena。 
  + [ 配置 Athena 分析 CloudTrail 日志 ](https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html)
+  在 AWS 中实施集中式日志记录：请参阅以下 AWS 示例解决方案来集中处理多个来源的日志记录。 
  +  [集中日志记录解决方案 ](https://aws.amazon.com/solutions/centralized-logging/https://aws.amazon.com/solutions/centralized-logging/)
+  通过合作伙伴集中处理日志记录：APN 合作伙伴拥有可以帮助您集中分析日志的解决方案。 
  + [ 日志记录和监控 ](https://aws.amazon.com/security/partner-solutions/#Logging_and_Monitoring)

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

 **相关文档：** 
+ [AWS Answers：集中式日志记录 ](https://aws.amazon.com/answers/logging/centralized-logging/)
+  [AWS Security Hub CSPM](https://docs.aws.amazon.com/securityhub/latest/userguide/what-is-securityhub.html) 
+ [ Amazon CloudWatch ](https://aws.amazon.com/cloudwatch/)
+  [Amazon EventBridge ](https://aws.amazon.com/eventbridge)
+ [ 开始使用：Amazon CloudWatch Logs ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_GettingStarted.html)
+  [安全合作伙伴解决方案：日志记录和监控](https://aws.amazon.com/security/partner-solutions/#logging-monitoring) 

 **相关视频：** 
+ [ 集中监控资源配置和合规性 ](https://youtu.be/kErRv4YB_T4)
+  [修正 Amazon GuardDuty 和 AWS Security Hub CSPM 调查结果 ](https://youtu.be/nyh4imv8zuk)
+ [ 云中的威胁管理：Amazon GuardDuty 和 AWS Security Hub CSPM](https://youtu.be/vhYsm5gq9jE)

# SEC04-BP03 自动响应事件
<a name="sec_detect_investigate_events_auto_response"></a>

 使用自动化流程调查和修复事件可减少人工处理工作量和人为错误，从而扩展调查功能。定期审核将帮助您优化自动化工具，并实现持续迭代。 

在 AWS 中，可以使用 Amazon EventBridge，调查感兴趣的事件以及自动化工作流程可能发生的意外变化的相关信息。此服务提供可扩展的规则引擎，可代理原生 AWS 事件格式（例如 AWS CloudTrail 事件）以及您可以从应用程序中生成的自定义事件。Amazon GuardDuty 还允许您将这些事件路由到构建意外事件响应系统（AWS Step Functions）的工作流程系统中，或者路由到中央安全账户或存储桶中以执行进一步分析。

检测更改并将此信息路由到正确的工作流的操作也可以使用 AWS Config 规则 和 [合规包](https://docs.aws.amazon.com/config/latest/developerguide/conformance-packs.html)完成。AWS Config 会检测对范围内服务的更改（虽然延迟会比 EventBridge 更高），并生成可使用 AWS Config 规则 进行解析的事件，以便进行回滚、强制实施合规性策略以及将信息转发到相关系统（如变更管理平台和运营票证系统）。除了编写您自己的 Lambda 函数以响应 AWS Config 事件，您还可以充分利用 [AWS Config 规则 开发工具包](https://github.com/awslabs/aws-config-rdk)以及 [一组开源](https://github.com/awslabs/aws-config-rules) AWS Config 规则。合规包是 AWS Config 规则 和修复操作的集合，您可将其作为以 YAML 模板格式创作的单个实体进行部署。一个 [示例合规包模板，](https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-wa-Security-Pillar.html) 面向 Well-Architected 安全性支柱提供。

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

## 实施指导
<a name="implementation-guidance"></a>
+  使用 GuardDuty 实施自动化警报：GuardDuty 是一种威胁检测服务，可持续监控恶意活动和未经授权的行为，从而保护您的 AWS 账户和工作负载。启用 GuardDuty 并配置自动化警报。 
+  自动执行调查流程：制定自动化流程来调查事件并向管理员报告信息，以便节省时间。 
  + [ 实验室：Amazon GuardDuty 动手实践 ](https://hands-on-guardduty.awssecworkshops.com/)

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

 **相关文档：** 
+ [AWS Answers：集中式日志记录 ](https://aws.amazon.com/answers/logging/centralized-logging/)
+  [AWS Security Hub CSPM](https://docs.aws.amazon.com/securityhub/latest/userguide/what-is-securityhub.html) 
+ [ Amazon CloudWatch ](https://aws.amazon.com/cloudwatch/)
+  [Amazon EventBridge ](https://aws.amazon.com/eventbridge)
+ [ 开始使用：Amazon CloudWatch Logs ](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_GettingStarted.html)
+  [安全合作伙伴解决方案：日志记录和监控](https://aws.amazon.com/security/partner-solutions/#logging-monitoring) 
+ [ 设置 Amazon GuardDuty ](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_settingup.html)

 **相关视频：** 
+ [ 集中监控资源配置和合规性 ](https://youtu.be/kErRv4YB_T4)
+  [修正 Amazon GuardDuty 和 AWS Security Hub CSPM 调查结果 ](https://youtu.be/nyh4imv8zuk)
+ [ 云中的威胁管理：Amazon GuardDuty 和 AWS Security Hub CSPM](https://youtu.be/vhYsm5gq9jE)

 **相关示例：** 
+  [实验室：自动部署检测性控制 ](https://wellarchitectedlabs.com/Security/200_Automated_Deployment_of_Detective_Controls/README.html)

# SEC04-BP04 实施可操作的安全事件
<a name="sec_detect_investigate_events_actionable_events"></a>

 创建发送给团队并将由团队处理的警报。确保警报包含团队采取措施所需的相关信息。对于您的每个检测性机制，您还应调查一个以 [运行手册](https://wa.aws.amazon.com/wat.concept.runbook.en.html) 或者 [行动手册](https://wa.aws.amazon.com/wat.concept.playbook.en.html)形式存在的流程。例如，当您启用 [Amazon GuardDuty](http://aws.amazon.com/guardduty)时，它会生成不同的 [调查结果](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_findings.html)。您的每个调查结果类型都应具有一个运行手册条目，例如，如果发现了 [特洛伊木马程序，](https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_trojan.html) 您的运行手册的简单说明可以指示某个人员进行调查和修复。

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

## 实施指导
<a name="implementation-guidance"></a>
+  发现可用于 AWS 服务的指标：发现可通过 Amazon CloudWatch 用于您正在使用的服务的指标。 
  +  [AWS 服务文档](https://aws.amazon.com/documentation/) 
  +  [使用 Amazon CloudWatch 指标](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/working_with_metrics.html) 
+  配置 Amazon CloudWatch 告警。 
  +  [使用 Amazon CloudWatch 告警](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html) 

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

 **相关文档：** 
+ [ Amazon CloudWatch ](https://aws.amazon.com/cloudwatch/)
+  [Amazon EventBridge ](https://aws.amazon.com/eventbridge)
+  [安全合作伙伴解决方案：日志记录和监控](https://aws.amazon.com/security/partner-solutions/#logging-monitoring) 

 **相关视频：** 
+ [ 集中监控资源配置和合规性 ](https://youtu.be/kErRv4YB_T4)
+  [修正 Amazon GuardDuty 和 AWS Security Hub CSPM 调查结果 ](https://youtu.be/nyh4imv8zuk)
+ [ 云中的威胁管理：Amazon GuardDuty 和 AWS Security Hub CSPM](https://youtu.be/vhYsm5gq9jE)