

# 偵測
<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 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html)可進一步保護 Amazon S3 中的日誌，您可以使用單寫多讀 (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)：GuardDuty 是威脅偵測服務，可持續尋找惡意活動和未經授權的行為，以保護 AWS 帳戶和工作負載。使用實驗室啟用 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) 系統。如此能使工作流程擺脫電子郵件和靜態報告，讓您能夠路由、向上呈報和管理事件或結果。許多組織也正在將安全提醒整合到其聊天或協作和開發人員生產力平台中。對於開始自動化的組織，以 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 都有管理員-成員模型，可跨多個帳戶彙總發現結果和洞見，其中使用 Security Hub CSPM 的客戶通常以內部部署的 SIEM 做為 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)。每種發現結果類型都應該在 Runbook 有一個輸入項目，例如，如果發現 [木馬程式](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)