使用 MS Sentinel playbooks進行威脅回應
Microsoft Sentinel playbook 是可以運作以回應告警的安全程序的集合。它可以用在以下微軟的產品:
- Microsoft Office 365
- Microsoft Entra ID
- Microsoft Entra ID Protection
- Defender for Cloud Apps
- Microsoft Defender for Identity
- Microsoft Defender for Endpoint
- Microsoft Defender for Office 365
- System Center Endpoint Protection
- Microsoft Azure Information Protection
組織透過使用 Microsoft Defender for Cloud 的付費版本為其基於 Azure 的資源和本機資源提供威脅防護。組織還可監控和保護其他非微軟資產。
一般的SecOps團隊對組織的最新安全事故的回應禿常不夠快。 C-Suites希望實施 Microsoft Sentinel playbooks來協助 SecOps 團隊識別並阻止潛在的安全威脅。
建立MS Sentinel playbook
作業一:佈署Microsoft Sentinel
- 進入Azure網站
- 在"Custom deployment"頁面輸入以下訊息
3. 選擇“Review + create”,然後在驗證資料有沒有錯後選擇“Create”。
作業二:檢查資源是否成功建立
- 在「Deployment Overview」頁面上,選擇「Go to resource group」。將顯示用於自訂部署的資源。
- 選擇Home,然後在 Azure 服務中搜尋並選擇Resource groups。
- 選擇 azure-sentinel-rg。
- 按Type對資源清單進行排序。
- 資源組應包含下表中所示的資源。
作業三: 配置Sentinel Connectors
- In the Azure portal, search for Microsoft Sentinel, and then select the previously created Microsoft Sentinel workspace.
- On the Microsoft Sentinel | Overview pane, in the left menu, scroll down to Content Management and select Content Hub
- In the Content Hub page, type Azure Activity into the Search form, and select the Azure Activity solution.
- In the Azure Activity solution details pane, select Install.
- In the center Content name column, select the Azure Activity Data connector.
- Select Open connector page
- In the Instructions/Configuration area, scroll down and under 2. Connect your subscriptions… select Launch Azure Policy Assignment Wizard.
- In the Basics tab of the wizard, select the ellipsis … under Scope. On the Scopes pane, select your subscription and then select Select.
- Select the Parameters tab, and choose your Microsoft Sentinel workspace from the Primary Log Analytics workspace drop-down list.
- Select the Remediation tab, and select the Create a remediation task checkbox. This action applies the policy assignment to already existing Azure resources.
- Select the Review + Create button to review the configuration, and then select Create.
作業四: 建立分析規則
- In the Azure portal, search for and select Microsoft Sentinel, and then select the previously created Microsoft Sentinel workspace.
- On the Microsoft Sentinel page, on the menu bar, in the Configuration section, select Analytics.
- On the Microsoft Sentinel | Analytics page, select Create and then select NRT Query Rule .
- On the General page, provide the inputs in the following table, and then select Next: Set rule logic >.
5. On the Set rule logic page, in the Rule query section, enter the following query:
AzureActivity
| where OperationNameValue == 'MICROSOFT.COMPUTE/VIRTUALMACHINES/DELETE'
| where ActivityStatusValue == 'Success'
| extend AccountCustomEntity = Caller
| extend IPCustomEntity = CallerIpAddress
6. Accept the default values for all other settings and then select Next: Incident setting.
7. On the Incident setting tab, ensure that Enabled is selected for creation of incidents from alerts triggered by this analytics rule. And then select Next: Automated response.
8. On the Automated response tab, you can select a playbook to run automatically when the alert is generated. Only the playbooks that contain a Logic App Microsoft Sentinel connector are displayed.
9. Select Next: Review.
10. On the Review and Create page, verify that the validation passed, and then select Create.
甚麼是Microsoft Sentinel playbooks?
組織除了評估和解決安全設定問題之外,通常還必須監控新問題和威脅,然後做出適當回應。Microsoft Sentinel 既是 SIEM 也是 SOAR 解決方案,專為混合雲環境而設計。
Microsoft Sentinel 使用內建和自訂偵測來提醒我們潛在的安全威脅,例如嘗試從其基礎結構外部存取組織的資源,或來自組織的資料似乎傳送到已知的惡意 IP 位址時。可以根據這些報警建立事件。
組織可以在 Microsoft Sentinel 中建立Security playbooks來回應告警。Security playbooks是基於 Azure Logic Apps的流程集合,這些Apps為回應告警而運作。可以手動執行這些Security playbooks以回應對事故的調查,也可以設定告警以自動執行playbook。
憑藉自動回應事件的能力,可以自動執行一些安全操作,並使SOC更有效率。
例如,為了解決 組織的問題,我們可以開發一個具有已定義步驟的工作流程,該工作流程可以阻止可疑使用者名稱從不安全的 IP 位址存取資源。或者,可以設定 playbook 來執行操作,例如通知 SecOps 團隊有關進階安全性告警的資訊。
Azure Logic Apps
Azure Logic Apps是一項雲端服務,可自動執行業務流程的作業。我們可以使用稱為Logic Apps Designer設計工具將預先建構的元件按需要的順序排列。也可以使用code view並在 JSON 檔案中編寫自動化流程。
Logic Apps Connector
Logic Apps使用連接器連接到數百個服務。連接器是提供外部服務介面的元件。
Triggers and actions
Azure Logic Apps使用Triggers和Actions,其定義如下:
- Trigger是滿足一組特定條件時發生的事件。滿足條件時觸發器(Trigger)會自動啟動。例如,Microsoft Sentinel 中發生安全性事故,這會觸發自動操作。
- Actions是在 Logic Apps workflow中執行任務的操作。當觸發器啟動、另一個Actions完成或滿足條件時,Actions就會運作。
Microsoft Sentinel Logic Apps connector
Microsoft Sentinel playbook 使用 Microsoft Sentinel Logic Apps connector。它提供了可以啟動playbook並執行所定義的行動的Trigger和Actions。
目前,Microsoft Sentinel Logic Apps connector有兩個Trigger:
- 當一個回應是針對Microsoft Sentinel告警被觸發時
- 當一個Microsoft Sentinel incident creation rule被觸發時
下表列出了 Microsoft Sentinel 連接器的所有目前操作。
某些Actions需要與其他連接器的Actions整合。例如,如果 我們想要識別在告警中從定義的實體(Entities)傳回的所有可疑帳號,則必須將「Entities — Get Accounts」 actions與「For Each」actions結合。同樣,要取得事故中偵測到可疑主機的所有單一主機,必須將「Entities — Get Hosts」actions與「For Each」actions結合。
及時觸發playbook
我們可以在 Playbooks 頁面上自動回應威脅。在此頁面上,可以觀察從 AzureLogic Apps建立的所有 playbook。Trigger kind這一欄位顯示logic app中使用的連接器類型。
使用header bar(如下圖所示)來建立新的 playbook 或啟用或停用現有的 playbook。
這個head bar提供了以下的選項:
- 使用Add Playbook 選項建立新的 Playbook。
- 在建立新的 playbook 後,使用「Refresh」選項刷新顯示。
- 使用下拉時間欄位來過濾 playbook 的運作狀態。
- 只有當選擇一個或多個logic apps時,「Enable」、「Disable」和「Delete」選項才可用。
- 使用邏Logic Apps documentation選項查看 Microsoft 官方文件的鏈接,以獲取有關logic apps的更多資訊。
如果我們希望使用自動化操作來防止可疑使用者存取其網路。作為他們的安全管理員,我們可以建立一個playbook來實施此操作。若要建立新的 Playbook,請選擇「Add Playbook」。我們將被導向到應透過提供以下設定的輸入來建立new logic app的頁面:
- Subscription. 選擇包含 Microsoft Sentinel 的訂閱。
- Resource Group. 可以使用現有資源組或建立新資源組。
- Logic App name. 為Logic App提供描述性名稱。
- Location. 選擇與 Log Analytics 工作區所在位置相同的位置。
- Log Analytics. 如果啟用 Log Analytics,則可以獲得有關 playbook 運作時事件的資訊。
提供這些輸入後,選擇「Review + Create」選項,然後選擇「 Create」。
Logic Apps Designer
Microsoft Sentinel 建立logic app,然後導向至Logic App Designer頁面。
Logic App Designer提供了一個設計畫布,可用於為工作流程新增觸發器和操作(trigger and actions)。例如,我們可以將觸發器設定為在建立新的安全事故時來自 Microsoft Sentinel 連接器。Logic App Designer頁面提供了許多可以使用的預先定義範本。但是,要建立Playbooks,我們應該從空白邏Logic App範本開始,從頭開始設計Logic App。
Playbook 中的自動化活動由 Microsoft Sentinel 觸發器啟動。可以在設計畫布的搜尋框中搜尋 Microsoft Sentinel 觸發器,然後選擇以下兩個可用觸發器之一:
- 當一個回應是針對Microsoft Sentinel告警被觸發時
- 當一個Microsoft Sentinel incident creation rule被觸發時
首次開啟 Microsoft Sentinel 連接器會提示我們使用 Microsoft Entra ID 中的使用者帳戶或Service Principal登入tenant。這將建立與我們的 Microsoft Entra ID 的 API connections。 API connections儲存存取連接 API 所需的 variables與tokens,例如 Microsoft Entra ID、Office 365 等。
每個Playbook都從觸發器開始,然後是定義安全事故自動回應的操作。可以將 Microsoft Sentinel 連接器中的Actions與其他Logic Apps connectors中的其他Actions組合。
例如,可以在觸發事故時從 Microsoft Sentinel 連接器新增觸發器,然後執行識別 Microsoft Sentinel 告警中的entities的操作,然後執行另一個將電子郵件傳送至 Office 365 電子郵件帳號的操作。 Microsoft Sentinel 將每個Actions建立為新步驟,並定義要在logic app中新增的活動。
以下圖示顯示了 Microsoft Sentinel 連接器觸發的事件,該連接器會偵測到可疑帳號並向管理員發送電子郵件。
工作流程設計中的每個步驟都有必須填寫的不同欄位。例如,「Entities — Get Accounts」操作要求須要有 Microsoft Sentinel 告警中的實體清單。使用 Azure Logic Apps的一個優點是,可以從動態內容清單中提供此輸入,該清單由上一個步驟的輸出填入。例如,Microsoft Sentinel connector trigger在觸發對 Microsoft Sentinel 告警的回應時提供動態屬性,例如實體、告警顯示名稱,我們可以使用這些屬性來填入Input。
也可以加入control actions group,讓logic app做出決策。control actions group可以包括邏輯條件、switch case conditions或loops。
Condition action是一個 if 語句,可讓應用程式根據正在處理的資料執行不同的操作。它由一個布林表達式和兩個操作組成。在運行時,執行引擎評估表達式並根據表達式是真還是假來選擇操作。
例如,組織收到大量告警,其中許多具有重複模式,無法處理或調查。使用即時自動化,SecOps 團隊可以透過完全自動化對重複類型告警的例行回應來大幅減少工作量。
以下圖示呈現了類似的情況,其中根據使用者輸入,Playbook可以更改告警的狀態。control action會攔截使用者輸入,如果表達式計算結果為 true 語句,則 playbook 會變更告警的狀態。如果control action將表達式計算為false,則Playbook可以執行其他活動,例如發送電子郵件,如以下圖示。
Microsoft Sentinel的Logic Apps
建立的 playbook 將顯示在 Playbooks 頁面上,可以進一步編輯它們。在「Playbooks」頁面中,可以選擇現有的 Playbook,這將在 Microsoft Sentinel 中開啟該 Playbook 的「Logic Apps」頁面。
我們可以從Logic Apps header bar對 playbook 執行多個操作:
- Run Trigger. 用於運行Logic App來測試playbook。
- Refresh. 用於刷新logic app的狀態以檢索活動的狀態。
- Edit. 用於在 Logic Apps Designer中進一步編輯playbook。
- Disable. 用於暫時停用logic app,以防止即使觸發器已啟動也無法執行操作。
- Update Schema. 用於邏輯發生重大變更後更新logic app的schema。
- Clone. 用於製作現有logic app的副本,然後將其用作進一步修改的基礎。
- Export. 用於將Logic app匯出到 Microsoft Power Automate 和 Microsoft Power Apps。
「要點」部分顯示有關logic app的描述性資訊。例如,logic app definition顯示logic app提供的triggers和actions的數量。
可以使用「Summary」部分來查看有關logic app的摘要資訊。在此部分中,可以選擇logic app link以在Logic Apps Designer中將其開啟或查看觸發器歷史記錄。
Runs history部分顯示logic app的先前運行以及它們是成功還是失敗。
最後一步,需要將此playbook附加到分析規則(analytics rule),以自動回應事故。可以使用分析規則中的自動回應部分來選擇產生告警時自動執行的 playbook。
Run playbooks on demand
在執行 playbook 之前,組織 的某些事故可能需要進一步調查。 Microsoft Sentinel 可讓我們On-Demand執行playbook以促進深入調查。
我們可以將 playbook 配置為根據事故詳細資訊按需運行、觸發特定步驟作為調查的一部分,或執行一些補救操作。
考量到阻止可疑使用者存取公司資源的場景。身為組織的安全管理員,我們發現了一起誤報事件。 組織的一些使用者透過VPN連接從遠端電腦存取資源,同時連接到辦公室電腦。 Microsoft Cloud Security 收到訊號後,根據偵測到來自非典型旅行地點的潛在威脅的漏洞,將使用者標記為中等風險。
我們可以使用可自動消除 Microsoft Entra ID 中此有風險的使用者屬性的 playbook。
Microsoft Sentinel repository on GitHub
GitHub 上的 Microsoft Sentinel 儲存庫包含即用型playbook,可協助組織自動回應事件。這些 playbook 透過使用邏Logic App Microsoft Sentinel triggers的 Azure Resource Manager (ARM template)進行定義。
對於前面描述的場景,可以使用 Dismiss-AADRiskyUser playbook(位於 GitHub 上的 Microsoft Sentinel 儲存庫中),並將其直接部署在 Azure 訂閱中。
對於來自 GitHub 的每個部署,首先必須對 playbook 中的每個連線進行授權,然後再在Logic Apps Designer中進行編輯。授權將建立到適當連接器的 API 連接並儲存token與variables。可以在建立logic app的資源群組中找到 API connection。
每個 API connection的名稱都附加 azuresentinel prefix。編輯logic app時,也可以在Logic Apps Designer中編輯連線。
Attach a playbook to an existing incident
Playbook準備好後,可以在 Microsoft Sentinel 中開啟「Incident」頁面,然後選擇現有事故。在詳細資料窗格中,可以選擇查看完整詳細資訊以查看事故的屬性。從“告警”面板中,可以選擇“View playbook”,然後可以執行現有的 playbook 之一。
以下圖示描述了可疑使用者活動範例,可以附加 Dismiss-AADRiskyUser playbook。