收集 AWS WAF 記錄
本文說明如何設定 Google Security Operations 資訊提供,以收集 AWS 網頁應用程式防火牆 (WAF) 記錄。剖析器會將原始 JSON 格式的記錄轉換為符合 Google SecOps UDM 的結構化格式。這項功能會擷取 IP 位址、網址、使用者代理程式和安全性規則詳細資料等欄位,並將這些欄位對應至相應的 UDM 欄位,以確保呈現和分析結果一致。
事前準備
*請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- AWS 的特殊存取權
設定 Amazon S3 儲存貯體
- 按照這份使用者指南建立 Amazon S3 值區:建立值區
- 儲存 bucket 的「名稱」和「區域」,以供後續使用。
- 按照這份使用者指南建立使用者:建立 IAM 使用者。
- 選取建立的「使用者」。
- 選取「安全憑證」分頁標籤。
- 在「Access Keys」部分中,按一下「Create Access Key」。
- 選取「第三方服務」做為「用途」。
- 點選「下一步」。
- 選用:新增說明標記。
- 按一下「建立存取金鑰」。
- 按一下「下載 CSV 檔案」,儲存「存取金鑰」和「私密存取金鑰」,以供日後使用。
- 按一下 [完成]。
- 選取 [權限] 分頁標籤。
- 在「權限政策」部分,按一下「新增權限」。
- 選取「新增權限」。
- 選取「直接附加政策」。
- 搜尋並選取 AmazonS3FullAccess 政策。
- 點選「下一步」。
- 按一下「新增權限」。
建立 WAF 網路 ACL (存取控制清單)
如果尚未設定 AWS WAF,請建立 WAF 網頁 ACL (存取控制清單)。如果是現有設定,請跳到下一個程序。
- 在 AWS 主控台中,搜尋並選取「AWS WAF & Shield」。
- 按一下「建立 Web ACL」。
- 提供下列設定:
- 名稱:為 ACL 命名 (例如
my-waf-web-acl
)。 - 區域:選擇要套用 WAF 的區域。
- CloudWatch 指標:啟用指標收集功能,追蹤活動和觸發的規則。
- 名稱:為 ACL 命名 (例如
- 建立完成後,請選取要啟用記錄的網路 ACL。
如何設定 AWS WAF 記錄
- 在 AWS WAF 主控台中,前往 Web ACL 的「Logging」分頁標籤。
- 按一下「啟用記錄功能」。
- 選取「Amazon S3」做為記錄檔目的地。
- 選擇先前建立的 S3 bucket 來儲存記錄。
- 選用:設定記錄檔前置字串,方便整理記錄檔 (例如
waf-logs/
)。 - 按一下 [儲存]。
驗證 S3 值區的權限
確保 S3 值區具備適當權限,可供 AWS WAF 寫入記錄。
- 前往 S3 控制台。
- 選取要儲存記錄的 bucket。
在「Permissions」(權限) 分頁中,新增下列 Bucket 政策,允許 AWS WAF 寫入記錄:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "wafv2.amazonaws.com" }, "Action": "s3:PutObject", "Resource": "arn:aws:s3:::your-log-bucket-name/*" } ] }
- 按一下 [儲存]。
設定動態饋給
在 Google SecOps 平台中,有兩種不同的進入點可設定動態饋給:
- 「SIEM 設定」>「動態消息」
- 內容中心 > 內容包
依序前往「SIEM 設定」>「動態消息」,設定動態消息
如要為這個產品系列中的不同記錄類型設定多個動態饋給,請參閱「設定多個動態饋給」。
如要設定單一動態饋給,請按照下列步驟操作:
- 依序前往「SIEM 設定」>「動態饋給」。
- 按一下「新增動態消息」。
- 在下一個頁面中,按一下「設定單一動態饋給」。
- 在「Feed name」(動態饋給名稱) 欄位中,輸入動態饋給的名稱 (例如「AWS WAF Logs」)。
- 選取「Amazon S3」做為「來源類型」。
- 選取「AWS WAF」做為「記錄類型」。
- 點選「下一步」。
指定下列輸入參數的值:
- 區域:Amazon S3 值區所在的區域。
- S3 URI:bucket URI。
s3://your-log-bucket-name/waf-logs/
- 取代下列項目:
your-log-bucket-name
:值區的實際名稱。
- 取代下列項目:
- URI 為:選取「Directory」或「Directory which includes subdirectories」。
- 來源刪除選項:根據擷取偏好設定選取刪除選項。
存取金鑰 ID:具備 S3 值區讀取權限的使用者存取金鑰。
存取密鑰:使用者的存取密鑰,具備從 S3 bucket 讀取的權限。
資產命名空間:資產命名空間。
擷取標籤:要套用至這個動態饋給事件的標籤。
點選「下一步」。
在「Finalize」畫面上檢查新的動態饋給設定,然後按一下「Submit」。
從內容中心設定動態饋給
為下列欄位指定值:
- 區域:Amazon S3 值區所在的區域。
- S3 URI:bucket URI。
s3://your-log-bucket-name/
- 請將
your-log-bucket-name
替換為 S3 值區的實際名稱。
- 請將
- URI 是:根據 bucket 結構,選取「Directory」(目錄) 或「Directory which includes subdirectories」(包含子目錄的目錄)。
- 來源刪除選項:根據擷取偏好設定選取刪除選項。
存取金鑰 ID:具備 S3 值區讀取權限的使用者存取金鑰。
存取密鑰:使用者的存取密鑰,具備從 S3 bucket 讀取的權限。
進階選項
- 動態饋給名稱:系統預先填入的值,用於識別動態饋給。
- 來源類型:將記錄收集到 Google SecOps 的方法。
- 資產命名空間:與動態饋給相關聯的命名空間。
- 擷取標籤:套用至這個動態饋給所有事件的標籤。
UDM 對應表
記錄欄位 | UDM 對應 | 邏輯 |
---|---|---|
動作 | security_result.action | 如果動作為 ALLOW,請將 security_result.action 設為 ALLOW,並將 security_result.severity 設為 INFORMATIONAL。如果動作為 BLOCK,請將 security_result.action 設為 BLOCK。如果動作是 CAPTCHA,且 captchaResponse.responseCode 為 405,請將 security_result.action 設為 BLOCK,並將 security_result.action_details 設為「CAPTCHA {captchaResponse.failureReason}」。 |
captchaResponse.failureReason | security_result.action_details | 與動作和 captchaResponse.responseCode 搭配使用,判斷 security_result.action_details。 |
captchaResponse.responseCode | security_result.action_details | 與動作和 captchaResponse.failureReason 搭配使用,判斷 security_result.action_details。 |
httpRequest.clientIp | principal.ip、principal.asset.ip | 直接對應至 principal.ip 和 principal.asset.ip。 |
httpRequest.headers | target.hostname、target.asset.hostname、network.http.user_agent、network.http.parsed_user_agent、network.http.referral_url、target.location.country_or_region、target.resource.attribute.labels、target.user.userid | 逐一疊代 httpRequest.headers 中的每個標頭。如果標頭名稱為「host」或「Host」,則值會對應至 target.hostname 和 target.asset.hostname。如果標頭名稱為「User-Agent」或「user-agent」,系統會將值對應至 network.http.user_agent,並剖析至 network.http.parsed_user_agent。如果標頭名稱為「Referer」或「referer」,則值會對應至 network.http.referral_url。如果標頭名稱為「(?i)time-zone」,則值會對應至 target.location.country_or_region。如果標頭名稱為「authorization」,系統會解碼該值、擷取使用者名稱,並對應至 target.user.userid。所有其他標頭都會以鍵/值組合的形式新增至 target.resource.attribute.labels。 |
httpRequest.httpMethod | network.http.method | 直接對應至 network.http.method。 |
httpRequest.requestId | network.session_id | 直接對應至 network.session_id。 |
httpRequest.uri | target.url | 直接對應至 target.url。 |
httpSourceId | target.resource.name | 直接對應至 target.resource.name。 |
httpSourceName | metadata.product_event_type | 直接對應至 metadata.product_event_type。 |
標籤 | security_result.rule_labels | 逐一疊代 labels 中的每個標籤。如果標籤名稱不是空白,系統會將其新增為鍵/值組合,加入 security_result.rule_labels。 |
nonTerminatingMatchingRules | security_result.action_details、security_result.rule_labels | 逐一疊代 nonTerminatingMatchingRules 中的每項規則。如果動作為 ALLOW 且規則動作為 CAPTCHA,請將 security_result.action_details 設為「CAPTCHA SUCCESSFUL」,並將規則 ID 新增至 security_result.rule_labels,並使用「nonTerminatingCaptchaRuleName」鍵。如果動作為 BLOCK 或 ALLOW,且規則動作為 COUNT,請將 security_result.action_details 設為「COUNT RULE」,並將規則 ID 新增至 security_result.rule_labels,金鑰為「nonTerminatingCountRuleName」。如果動作為 BLOCK 或 ALLOW,且規則動作為 CHALLENGE,請將 security_result.action_details 設為「COUNT RULE」,並在 security_result.rule_labels 中加入規則 ID,並使用「nonTerminatingChallengeRuleName」鍵。 |
rateBasedRuleList | security_result.rule_id、security_result.rule_name、security_result.description | 如果 terminatingRuleType 為「RATE_BASED」,則會逐一疊代 rateBasedRuleList 中的每個規則。如果 terminatingRuleId 與規則名稱相符,規則 ID、規則名稱和說明會分別對應至 security_result.rule_id、security_result.rule_name 和 security_result.description。 |
responseCodeSent | network.http.response_code | 直接對應至 network.http.response_code,並轉換為整數。 |
ruleGroupList | intermediary.labels、security_result.rule_id、security_result.rule_name、security_result.description、security_result.detection_fields | 逐一疊代 ruleGroupList 中的每個規則群組。系統會將規則群組 ID 以鍵/值組合的形式,新增至 intermediary.labels。如果 terminatingRuleType 為「MANAGED_RULE_GROUP」,且 terminatingRuleId 與規則群組 ID 相符,則規則 ID、規則名稱和說明會分別對應至 security_result.rule_id、security_result.rule_name 和 security_result.description。如果 terminatingRuleType 為「GROUP」,系統會擷取終止規則 ID,並對應至 security_result.rule_name 和 security_result.description。終止規則群組 ID 會新增至 security_result.rule_labels,並以「terminatingRuleGroupName」做為鍵。如果 terminatingRuleType 為「REGULAR」,系統會擷取終止規則動作,並以「terminatingRuleAction{index}」鍵新增至 security_result.detection欄位。 |
terminatingRuleId | security_result.rule_id、security_result.rule_name、security_result.description | 如果 terminatingRuleType 為「RATE_BASED」、「MANAGED_RULE_GROUP」或「REGULAR」,terminatingRuleId 會對應至 security_result.rule_id、security_result.rule_name,並用於建構 security_result.description。 |
terminatingRuleMatchDetails | security_result.description、security_result.category_details、security_result.detection_fields | 逐一疊代 terminatingRuleMatchDetails 中的每個相符項目。將 security_result.description 設為「Terminating Rule」。如果條件類型不是空白,系統會將其新增至 security_result.category_details。如果位置資訊不為空白,系統會將其新增至 security_result.detection_fields,並使用「location」鍵。系統會將每個相符的資料元素新增至 security_result.detection_fields,並使用「matchedData」鍵。 |
terminatingRuleType | security_result.rule_type | 直接對應至 security_result.rule_type。 |
時間戳記 | metadata.event_timestamp | 轉換為時間戳記,並對應至 metadata.event_timestamp。 |
webaclId | intermediary.resource.name | 直接對應至 intermediary.resource.name。 |
metadata.vendor_name | 設為「AMAZON」。 | |
metadata.product_name | 設為「AWS Web 應用程式防火牆」。 | |
metadata.log_type | 設為「AWS_WAF」。 | |
network.application_protocol | 設為「HTTP」。 | |
metadata.event_type | 如果 httpRequest.headers 包含「host」或「Host」標頭,請設為「NETWORK_HTTP」。否則請設為「STATUS_UPDATE」。 |
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。