使用Sentinel建置雲端SIEM 是做什麼的?
使用時機
- 為多雲端環境建立集中式安全營運中心時
- 從傳統SIEM平台(Splunk、QRadar)遷移至雲端原生架構時
- 為雲端特定威脅建置自動化事件回應流程時
- 跨PB級安全遙測資料執行大規模威脅狩獵時
- 將威脅情資摘要與雲端安全記錄分析整合時
請勿使用於僅需AWS Security Hub和GuardDuty即可滿足的AWS-only環境、需要EDR功能的端點偵測(請使用Defender for Endpoint),或法規遵循狀態監控(請參閱建置雲端安全態勢管理)。
先決條件
- 具有已啟用Microsoft Sentinel的Log Analytics工作區的Azure訂閱
- 目標記錄來源(AWS CloudTrail、Azure Activity、GCP)的資料連接器權限
- 用於自動化回應腳本的Logic Apps或Azure Functions
- 具備KQL(Kusto查詢語言)能力,用以撰寫偵測規則和狩獵查詢
工作流程
步驟1:佈建Sentinel工作區與資料連接器
建立針對安全資料最佳化的Log Analytics工作區,並啟用多雲端資料擷取的連接器。
# 建立Log Analytics工作區
az monitor log-analytics workspace create \
--resource-group security-rg \
--workspace-name sentinel-workspace \
--location eastus \
--retention-time 365 \
--sku PerGB2018
# 在工作區上啟用Microsoft Sentinel
az sentinel onboarding-state create \
--resource-group security-rg \
--workspace-name sentinel-workspace
# 啟用AWS CloudTrail連接器
az sentinel data-connector create \
--resource-group security-rg \
--workspace-name sentinel-workspace \
--data-connector-id aws-cloudtrail \
--kind AmazonWebServicesCloudTrail \
--aws-cloud-trail-data-connector '{
"awsRoleArn": "arn:aws:iam::123456789012:role/SentinelCloudTrailRole",
"dataTypes": {"logs": {"state": "Enabled"}}
}'
# 啟用Azure AD登入與稽核記錄
az sentinel data-connector create \
--resource-group security-rg \
--workspace-name sentinel-workspace \
--data-connector-id azure-ad \
--kind AzureActiveDirectory \
--azure-active-directory '{
"dataTypes": {
"alerts": {"state": "Enabled"},
"signinLogs": {"state": "Enabled"},
"auditLogs": {"state": "Enabled"}
}
}'
步驟2:撰寫KQL偵測規則
使用Kusto查詢語言建立分析規則,以偵測雲端特定威脅。將每個規則對應至MITRE ATT&CK技術。
// 偵測不可能移動 - 從地理上相距遙遠的地點登入
let timeframe = 1h;
let distance_threshold = 500; // km
SigninLogs
| where TimeGenerated > ago(timeframe)
| where ResultType == 0 // 僅限成功登入
| project TimeGenerated, UserPrincipalName, IPAddress, Location,
Latitude = toreal(LocationDetails.geoCoordinates.latitude),
Longitude = toreal(LocationDetails.geoCoordinates.longitude)
| sort by UserPrincipalName asc, TimeGenerated asc
| extend PrevLatitude = prev(Latitude, 1), PrevLongitude = prev(Longitude, 1),
PrevTime = prev(TimeGenerated, 1), PrevUser = prev(UserPrincipalName, 1)
| where UserPrincipalName == PrevUser
| extend TimeDiff = datetime_diff('minute', TimeGenerated, PrevTime)
| where TimeDiff < 60
| extend Distance = geo_distance_2points(Longitude, Latitude, PrevLongitude, PrevLatitude) / 1000
| where Distance > distance_threshold
| project TimeGenerated, UserPrincipalName, IPAddress, Location, Distance, TimeDiff
// 從CloudTrail偵測AWS IAM憑證濫用
AWSCloudTrail
| where TimeGenerated > ago(24h)
| where EventName in ("ConsoleLogin", "AssumeRole", "GetSessionToken")
| where ErrorCode == ""
| summarize LoginCount = count(), DistinctIPs = dcount(SourceIpAddress),
IPList = make_set(SourceIpAddress, 10)
by UserIdentityArn, bin(TimeGenerated, 1h)
| where DistinctIPs > 3
| project TimeGenerated, UserIdentityArn, LoginCount, DistinctIPs, IPList
// 偵測大量S3物件刪除(潛在勒索軟體)
AWSCloudTrail
| where TimeGenerated > ago(1h)
| where EventName == "DeleteObject" or EventName == "DeleteObjects"
| summarize DeleteCount = count(), BucketsAffected = dcount(RequestParameters_bucketName)
by UserIdentityArn, bin(TimeGenerated, 10m)
| where DeleteCount > 100
| project TimeGenerated, UserIdentityArn, DeleteCount, BucketsAffected
步驟3:使用Logic Apps建置SOAR腳本
建立自動化回應腳本,在分析規則觸發事件時執行。常見動作包括封鎖使用者、隔離資源,以及使用威脅情資豐富警示。
{
"definition": {
"triggers": {
"Microsoft_Sentinel_incident": {
"type": "ApiConnectionWebhook",
"inputs": {
"body": {"incidentArmId": "subscriptions/@{triggerBody()?['workspaceInfo']?['SubscriptionId']}/resourceGroups/@{triggerBody()?['workspaceInfo']?['ResourceGroupName']}/providers/Microsoft.OperationalInsights/workspaces/@{triggerBody()?['workspaceInfo']?['WorkspaceName']}/providers/Microsoft.SecurityInsights/Incidents/@{triggerBody()?['object']?['properties']?['incidentNumber']}"},
"host": {"connection": {"name": "@parameters('$connections')['microsoftsentinel']['connectionId']"}}
}
}
},
"actions": {
"Get_incident_entities": {
"type": "ApiConnection",
"inputs": {"method": "post", "path": "/Incidents/entities"}
},
"For_each_account_entity": {
"type": "Foreach",
"foreach": "@body('Get_incident_entities')?['Accounts']",
"actions": {
"Disable_Azure_AD_user": {
"type": "ApiConnection",
"inputs": {
"method": "PATCH",
"path": "/v1.0/users/@{items('For_each_account_entity')?['AadUserId']}",
"body": {"accountEnabled": false}
}
},
"Add_comment_to_incident": {
"type": "ApiConnection",
"inputs": {
"body": {"message": "使用者 @{items('For_each_account_entity')?['Name']} 已由自動化腳本停用"}
}
}
}
}
}
}
}
步驟4:配置Sentinel資料湖以進行長期狩獵
啟用Sentinel資料湖以進行PB級紀錄保留,並使用KQL和SQL端點進行進階威脅狩獵。
// 威脅狩獵查詢:偵測跨AWS帳戶的橫向移動
let suspicious_roles = AWSCloudTrail
| where TimeGenerated > ago(7d)
| where EventName == "AssumeRole"
| extend AssumedRoleArn = tostring(parse_json(RequestParameters).roleArn)
| where AssumedRoleArn contains "cross-account" or AssumedRoleArn contains "admin"
| summarize AssumeCount = count(), UniqueSourceAccounts = dcount(RecipientAccountId)
by UserIdentityArn, AssumedRoleArn
| where AssumeCount > 10 and UniqueSourceAccounts > 2;
suspicious_roles
| join kind=inner (
AWSCloudTrail
| where TimeGenerated > ago(7d)
| where EventName in ("RunInstances", "CreateFunction", "PutBucketPolicy")
) on UserIdentityArn
| project TimeGenerated, UserIdentityArn, AssumedRoleArn, EventName, SourceIpAddress
步驟5:整合威脅情資
連接威脅情資提供者,並建立基於指標的比對規則,以偵測與已知惡意基礎設施的通訊。
# 啟用Microsoft Threat Intelligence連接器
az sentinel data-connector create \
--resource-group security-rg \
--workspace-name sentinel-workspace \
--data-connector-id microsoft-ti \
--kind MicrosoftThreatIntelligence \
--microsoft-threat-intelligence '{
"dataTypes": {"microsoftEmergingThreatFeed": {"lookbackPeriod": "2025-01-01T00:00:00Z", "state": "Enabled"}}
}'
// 將網路指標與雲端流程記錄進行比對
let TI_IPs = ThreatIntelligenceIndicator
| where TimeGenerated > ago(30d)
| where isnotempty(NetworkIP)
| distinct NetworkIP;
AzureNetworkAnalytics_CL
| where TimeGenerated > ago(24h)
| where DestIP_s in (TI_IPs)
| project TimeGenerated, SrcIP_s, DestIP_s, DestPort_d, FlowType_s
關鍵概念
| 術語 | 定義 |
|---|---|
| KQL | Kusto查詢語言,Microsoft Sentinel的主要查詢語言,用於搜尋、分析和視覺化安全資料 |
| 分析規則 | Sentinel中的偵測邏輯,會依排程評估記錄資料,並在條件符合時建立事件 |
| SOAR腳本 | 由事件觸發的自動化工作流程,執行諸如封鎖帳戶、豐富警示或通知團隊等回應動作 |
| 資料連接器 | 將安全記錄從雲端服務、身分提供者和第三方工具擷取至Sentinel的整合模組 |
| Sentinel資料湖 | PB級儲存層,提供長期記錄保留,並支援KQL和SQL查詢介面,用於進階狩獵 |
| 活頁簿 | Sentinel中的互動式儀表板,顯示安全資料的視覺化圖表、趨勢和營運指標 |
| 監看清單 | Sentinel中的參考資料表,用於豐富警示的上下文,例如VIP使用者清單或核准的IP範圍 |
| Fusion偵測 | 機器學習驅動的關聯引擎,能自動偵測跨資料來源的多階段攻擊 |
工具與系統
- Microsoft Sentinel: 基於Azure Log Analytics的雲端原生SIEM/SOAR平台,具備AI驅動的威脅偵測能力
- Azure Logic Apps: 低程式碼自動化平台,用於建置由Sentinel事件觸發的SOAR腳本
- Microsoft Threat Intelligence: 整合的威脅摘要,提供IP、網域和URL指標,用於與安全記錄進行比對
- Azure Data Explorer: 高效能分析引擎,為Sentinel KQL查詢提供基礎,支援大規模資料探索
- MITRE ATT&CK Navigator: 用於將Sentinel偵測規則對應至對手戰術和技術的框架
常見情境
情境:偵測跨雲端憑證竊取活動
背景:攻擊者透過網路釣魚入侵Azure AD帳戶,然後使用該帳戶透過同盟身分存取AWS資源。Sentinel需要將Azure登入異常與異常的AWS API活動進行關聯。
方法:
- 建立偵測Azure AD不可能移動或異常登入風險的分析規則
- 撰寫KQL查詢,將受入侵的Azure AD身分與AWS CloudTrail AssumeRoleWithSAML事件進行關聯
- 建立Fusion偵測規則,將Azure AD風險事件與隨後的AWS權限提升活動連結起來
- 部署SOAR腳本,自動停用Azure AD帳戶並撤銷AWS STS工作階段
- 建立活頁簿,顯示從初始入侵到AWS橫向移動的完整時間線
- 在資料湖中執行狩獵查詢,檢查是否有影響其他帳戶的類似模式
陷阱:未能跨雲端提供者關聯身分會遺漏完整的攻擊鏈。將分析規則頻率設定過低(例如24小時)會讓攻擊者擁有數小時的未偵測存取時間。
輸出格式
Microsoft Sentinel SOC Operations Report
==========================================
工作區:sentinel-workspace
資料來源:14個活躍連接器
報告期間:2025-02-01 至 2025-02-23
資料擷取:
Azure AD 登入記錄: 2.3 TB (23天)
AWS CloudTrail: 1.8 TB (23天)
Azure Activity: 0.9 TB (23天)
Defender for Cloud 警示:45 GB (23天)
總擷取量: 5.1 TB
偵測摘要:
活躍分析規則:87
建立的事件:234
重大:8 | 高:34 | 中:89 | 低:103
平均偵測時間(MTTD):4.2分鐘
平均回應時間(MTTR):18分鐘
主要事件類型:
偵測到不可能移動: 42個事件
AWS未授權API呼叫模式: 28個事件
S3中的大量檔案刪除: 3個事件
可疑的Azure AD應用程式註冊:12個事件
自動化:
已執行的腳本:156
自動停用的帳戶:23
自動豐富的事件:198
誤報率:12%