

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Microsoft Sentinel 中擷取和分析 AWS 安全日誌
<a name="ingest-analyze-aws-security-logs-sentinel"></a>

*Ivan Girardi 和 Sebastian Wenzel，Amazon Web Services*

## 總結
<a name="ingest-analyze-aws-security-logs-sentinel-summary"></a>

此模式說明如何將 AWS 安全日誌，例如 AWS CloudTrail 日誌、Amazon CloudWatch Logs 資料、Amazon VPC Flow Logs 資料和 Amazon GuardDuty 調查結果，自動擷取至 Microsoft Sentinel。如果您的組織使用 Microsoft Sentinel 做為安全資訊和事件管理 (SIEM) 系統，這可協助您集中監控和分析日誌，以偵測與安全相關的事件。一旦日誌可供使用，它們會在不到 5 分鐘內自動交付到 Amazon Simple Storage Service (Amazon S3) 儲存貯體。這可協助您快速偵測 AWS 環境中的安全事件。

Microsoft Sentinel 會以表格格式擷取 CloudTrail 日誌，其中包含記錄事件時的原始時間戳記。擷取日誌的結構可透過在 Microsoft Sentinel 中使用 [Kusto 查詢語言來啟用查詢](https://learn.microsoft.com/en-us/azure/sentinel/kusto-overview)功能。

模式會部署監控和提醒解決方案，可在不到 1 分鐘內偵測擷取失敗。它還包含外部 SIEM 可以監控的通知系統。您可以使用 AWS CloudFormation 在記錄帳戶中部署所需的資源。

**目標對象**

建議具有 AWS Organizations CloudFormation AWS Control Tower、 AWS Identity and Access Management (IAM) 和 AWS Key Management Service () 相關經驗的使用者使用此模式AWS KMS。

## 先決條件和限制
<a name="ingest-analyze-aws-security-logs-sentinel-prereqs"></a>

**先決條件**

以下是部署此解決方案的先決條件：
+ 在 中以組織身分管理 AWS 帳戶 的作用中 AWS Organizations ，是 AWS Control Tower 登陸區域的一部分。組織應包含用於記錄的專用帳戶。如需說明，請參閱 AWS Organizations 文件中的[建立和設定組織](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_tutorials_basic.html)。
+ CloudTrail 追蹤會記錄整個組織的事件，並將日誌存放在記錄帳戶中的 Amazon S3 儲存貯體中。如需說明，請參閱[建立組織的追蹤](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html)。
+ 在記錄帳戶中，擔任具有下列許可之現有 IAM 角色的許可：
  + 部署在提供的 CloudFormation 範本中定義的資源。
  + 部署提供的 CloudFormation 範本。
  + 如果使用客戶受管 AWS KMS 金鑰加密日誌，請修改金鑰政策。
+ AWS Command Line Interface (AWS CLI)，[已安裝](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)並[設定](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)。
+ 訂閱使用 Microsoft Sentinel 的 Microsoft Azure 帳戶。
+ 啟用和設定 Microsoft Sentinel。如需說明，請參閱 [Microsoft Sentinel 文件中的啟用 Microsoft Sentinel 和初始功能和內容](https://learn.microsoft.com/en-us/azure/sentinel/enable-sentinel-features-content)。
+ 符合設定 Microsoft Sentinel S3 連接器的先決條件。

**限制**
+ 此解決方案會將安全日誌從記錄帳戶中的 Amazon S3 儲存貯體轉送至 Microsoft Sentinel。未明確提供如何將日誌傳送至 Amazon S3 的說明。
+ 此模式提供 AWS Control Tower 在登陸區域中部署的指示。不過， AWS Control Tower 不需要使用 。
+ 此解決方案相容於 Amazon S3 記錄儲存貯體受到[服務控制政策 (SCPs)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html) 限制的環境，例如[不允許在日誌存檔中變更 AWS Control Tower 已建立的 Amazon S3 儲存貯體的儲存貯體政策](https://docs.aws.amazon.com/controltower/latest/controlreference/mandatory-controls.html#disallow-policy-changes-s3-buckets-created)。
+ 此模式提供轉送 CloudTrail 日誌的指示，但您可以調整此解決方案來傳送 Microsoft Sentinel 支援的其他日誌，例如來自 CloudWatch Logs、Amazon VPC Flow Logs 和 GuardDuty 的日誌。
+ 這些指示使用 AWS CLI 部署 CloudFormation 範本，但您也可以使用 AWS 管理主控台。如需說明，請參閱[使用 AWS CloudFormation 主控台](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-console.html)。如果您使用 主控台部署堆疊，請將堆疊部署在 AWS 區域 與記錄儲存貯體相同的 中。
+ 此解決方案會部署 Amazon Simple Queue Service (Amazon SQS) 佇列來傳送 Amazon S3 通知。佇列包含的訊息包含 Amazon S3 儲存貯體中上傳物件的路徑，而非實際資料。佇列使用 SSE-SQS 加密協助保護訊息的內容。如果您想要使用 SSE-KMS 加密 SQS 佇列，您可以使用客戶管理的 KMS 金鑰。如需詳細資訊，請參閱 [Amazon SQS 中的靜態加密](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html)。

## Architecture
<a name="ingest-analyze-aws-security-logs-sentinel-architecture"></a>

本節提供範本程式碼建立之架構的高階概觀。下圖顯示日誌帳戶中部署的資源，以便將日誌從現有的 Amazon S3 儲存貯體擷取到 Microsoft Sentinel。

![\[Microsoft Sentinel 使用 Amazon SNS 佇列從 S3 儲存貯體擷取日誌\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/e8438b44-6bce-4863-8657-1d0a843ffb6f/images/38108d9d-88ad-4306-8ad2-01b66a6bf00f.png)


架構圖顯示下列資源互動：

1. 在記錄帳戶中，Microsoft Sentinel 透過 OpenID Connect (OIDC) 擔任 IAM 角色，以存取特定 Amazon S3 儲存貯體和 Amazon SQS 佇列中的日誌。

1. Amazon Simple Notification Service (Amazon SNS) 和 Amazon S3 AWS KMS 用於加密。

1. 每當 Amazon S3 收到新日誌時，就會傳送通知訊息至 Amazon SQS 佇列。

1. Microsoft Sentinel 會檢查 Amazon SQS 是否有新訊息。Amazon SQS 佇列使用 SSE-SQS 加密。訊息保留期設定為 14 天。

1. Microsoft Sentinel 會從 Amazon SQS 佇列提取訊息。訊息包含已上傳 Amazon S3 物件的路徑。Microsoft Sentinel 會將這些物件從 Amazon S3 儲存貯體擷取至 Microsoft Azure 帳戶。

1. CloudWatch 警示會監控 Amazon SQS 佇列。如果未在 5 分鐘內從 Amazon SQS 佇列接收和刪除訊息，則會啟動傳送電子郵件的 Amazon SNS 通知。

AWS Control Tower 可協助您設定基礎組織單位 (OU) 結構，並將 CloudTrail 日誌集中在記錄帳戶中。它還實作強制性 SCPs 來保護記錄儲存貯體。

我們已在 AWS Control Tower 登陸區域中提供目標架構，但這並非嚴格要求。在此圖中，管理帳戶中的資源反映了 的 AWS Control Tower 部署和 CloudTrail 追蹤，可記錄整個組織的事件。

此模式著重於日誌帳戶中資源的部署。如果存放在 AWS Control Tower 登陸區域中 Amazon S3 中的日誌使用客戶受管 KMS 金鑰加密，則您必須更新金鑰政策，以允許 Microsoft Sentinel 解密日誌。在 AWS Control Tower 登陸區域中，您可以從管理帳戶管理金鑰政策，這是建立金鑰的位置。

## 工具
<a name="ingest-analyze-aws-security-logs-sentinel-tools"></a>

**AWS 服務**
+ [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html) 可協助您設定 AWS 資源、快速且一致地佈建資源，以及在整個 AWS 帳戶 和 區域的生命週期中管理資源。
+ [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) 可協助您 AWS 即時監控 AWS 資源的指標，以及您在其上執行的應用程式。
+ [AWS Control Tower](https://docs.aws.amazon.com/controltower/latest/userguide/what-is-control-tower.html) 可協助您設定和管理 AWS 多帳戶環境，並遵循最佳實務。
+ [AWS Key Management Service (AWS KMS)](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html) 可協助您建立和控制密碼編譯金鑰，以協助保護您的資料。
+ [AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html) 是一種帳戶管理服務，可協助您將多個 合併 AWS 帳戶 到您建立並集中管理的組織。
+ [Amazon Simple Queue Service (Amazon SQS)](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html) 提供安全、耐用且可用的託管佇列，可協助您整合和分離分散式軟體系統和元件。
+ [Amazon Simple Storage Service (Amazon S3)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html) 是一種雲端型物件儲存服務，可協助您儲存、保護和擷取任何數量的資料。

**其他工具**
+ [Microsoft Sentinel](https://learn.microsoft.com/en-us/azure/sentinel/overview) 是一種雲端原生 SIEM 系統，可提供安全協同運作、自動化和回應 (SOAR)。

**程式碼儲存庫**

此模式的程式碼可在 GitHub [擷取中取得，並分析 Microsoft Sentinel 儲存庫中的 AWS 安全日誌](https://github.com/aws-samples/ingest-and-analyze-aws-security-logs-in-microsoft-sentinel)。

## 最佳實務
<a name="ingest-analyze-aws-security-logs-sentinel-best-practices"></a>
+ 遵循[最低權限原則 ](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege)(IAM 文件）。
+ 遵循[AWS Control Tower 管理員的最佳實務 ](https://docs.aws.amazon.com/controltower/latest/userguide/best-practices.html)(AWS Control Tower 文件）。
+ 遵循[AWS CloudFormation 最佳實務](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html) (CloudFormation 文件）。
+ 使用程式碼分析工具，例如 [cfn\$1nag](https://github.com/stelligent/cfn_nag)，掃描產生的 CloudFormation 範本。cfn\$1nag 工具透過搜尋模式來識別 CloudFormation 範本中的潛在安全問題。

## 史詩
<a name="ingest-analyze-aws-security-logs-sentinel-epics"></a>

### 將 Microsoft Sentinel 連線至 Amazon S3
<a name="connect-microsoft-sentinel-to-s3"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 準備 Microsoft Sentinel S3 連接器。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/ingest-analyze-aws-security-logs-sentinel.html) | DevOps 工程師，一般 AWS | 

### 部署 CloudFormation 堆疊
<a name="deploy-the-cfnshort-stack"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 複製儲存庫。 | 在 bash shell 中，輸入下列命令。這會複製[擷取和分析 Microsoft Sentinel 儲存庫中的 AWS 安全日誌](https://github.com/aws-samples/ingest-and-analyze-aws-security-logs-in-microsoft-sentinel)。`git clone https://github.com/aws-samples/ingest-and-analyze-aws-security-logs-in-microsoft-sentinel.git` | DevOps 工程師，一般 AWS | 
| 擔任記錄帳戶中的 IAM 角色。 | 在記錄帳戶中，擔任具有部署 CloudFormation 堆疊許可的 IAM 角色。如需在 中擔任 IAM 角色的詳細資訊 AWS CLI，請參閱[在 中使用 IAM 角色 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html)。 | DevOps 工程師，一般 AWS | 
| 部署堆疊。 | 若要部署 CloudFormation 堆疊，請輸入下列命令：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/ingest-analyze-aws-security-logs-sentinel.html)<pre>aws cloudformation deploy --stack-name cloudtrail-sentinel-integration \<br />    --no-fail-on-empty-changeset \<br />    --template-file template.yml \<br />    --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \<br />    --parameter-overrides \<br />    ControlTowerS3BucketName="<Bucket name>" \<br />    AzureWorkspaceID="<Sentinel external ID>" \<br />    EmailAddress="<Email address>" \<br />    KMSKeyArn="<Customer managed key ARN>" \<br />    Suffix="<Suffix to avoid name conflicts>" \<br />    OIDCProviderArn="<ARN for the OIDC provider>"</pre> | DevOps 工程師，一般 AWS | 
| 複製輸出。 | 從 CloudFormation 堆疊的輸出中，複製 `SentinelRoleArn`和 的值`SentinelSQS`。您稍後使用這些值來完成 Microsoft Sentinel 中的組態。 | DevOps 工程師，一般 AWS | 
| 修改金鑰政策。 | 如果您不是使用客戶受管 KMS 金鑰來加密 Amazon S3 儲存貯體中的日誌，則可以略過此步驟。如果日誌使用客戶受管 KMS 金鑰加密，請修改金鑰政策以授予 Microsoft Sentinel 解密日誌的許可。金鑰政策範例如下。如果 KMS 金鑰位於另一個 中，則此範例政策允許跨帳戶存取 AWS 帳戶。<pre>{<br />    "Version": "2012-10-17",		 	 	 <br />    "Id": "key-policy",<br />    "Statement": [<br />        ...<br />        {<br />            "Sid": "Grant access to decrypt",<br />            "Effect": "Allow",<br />            "Principal": {<br />                "AWS": "<SentinelRoleArn>"<br />            },<br />            "Action": "kms:Decrypt",<br />            "Resource": "<KeyArn>"<br />        }<br />    ]<br />}</pre> | DevOps 工程師，一般 AWS | 

### 在 Microsoft Sentinel 中設定連接器
<a name="configure-the-connector-in-microsoft-sentinel"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 完成 Microsoft Sentinel 中的組態。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/ingest-analyze-aws-security-logs-sentinel.html) | DevOps 工程師 | 
| 將 Amazon S3 事件通知傳送至 Amazon SQS。 | 遵循[使用 Amazon S3 主控台啟用和設定事件通知](https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-event-notifications.html)中的指示，以設定 Amazon S3 記錄儲存貯體將事件通知傳送至 Amazon SQS 佇列。如果已為整個組織設定 CloudTrail，則此儲存貯體中的日誌具有字首 `<OrgID>/AWSLogs/<OrgID>/`，其中 `<OrgID>`是組織 ID。如需詳細資訊，請參閱[檢視組織的詳細資訊](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_details.html)。 | DevOps 工程師，一般 AWS | 
| 確認日誌已擷取。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/ingest-analyze-aws-security-logs-sentinel.html) | DevOps 工程師 | 

### 驗證解決方案
<a name="validate-the-solution"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 比較 CloudWatch 和 Sentinel 日誌。 | 在 的預設組態中 AWS Control Tower，CloudTrail 日誌會傳送至 Amazon CloudWatch，並存放在 AWS Control Tower 管理帳戶中。如需詳細資訊，請參閱在 [中記錄和監控 AWS Control Tower](https://docs.aws.amazon.com/controltower/latest/userguide/logging-and-monitoring.html)。使用下列步驟來確認日誌會自動擷取至 Microsoft Sentinel：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/ingest-analyze-aws-security-logs-sentinel.html) | DevOps 工程師，一般 AWS | 

## 相關資源
<a name="ingest-analyze-aws-security-logs-sentinel-resources"></a>

**AWS 文件和資源**
+ [AWS CLI 命令參考](https://docs.aws.amazon.com/cli/latest/) (AWS CLI 文件）
+ [選擇性設定 AWS KMS keys](https://docs.aws.amazon.com/controltower/latest/userguide/configure-kms-keys.html) (AWS Control Tower 文件）
+ [Amazon SQS 中的靜態加密](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html) (Amazon SQS 文件）
+ [如何防止郵寄清單收件人取消訂閱 Amazon SNS 主題電子郵件清單中的每個人？](https://repost.aws/knowledge-center/prevent-unsubscribe-all-sns-topic) (AWS 知識中心）

**Microsoft 文件**
+ [將 Microsoft Sentinel 連線至 Amazon Web Services 以擷取 AWS 服務日誌資料](https://learn.microsoft.com/en-us/azure/sentinel/connect-aws?tabs=s3)
+ [Microsoft Sentinel 中的 Kusto 查詢語言](https://learn.microsoft.com/en-us/azure/sentinel/kusto-overview)