收集 AWS WAF 日志
本文档介绍了如何通过设置 Google Security Operations Feed 来收集 AWS Web 应用防火墙 (WAF) 日志。解析器会将原始 JSON 格式的日志转换为符合 Google SecOps UDM 的结构化格式。它会提取 IP 地址、网址、用户代理和安全规则详细信息等字段,并将它们映射到相应的 UDM 字段,以便进行一致的表示和分析。
准备工作
*确保您满足以下前提条件:
- Google SecOps 实例
- 对 AWS 的特权访问权限
配置 Amazon S3 存储桶
- 按照以下用户指南创建 Amazon S3 存储桶:创建存储桶
- 保存存储桶名称和区域以备后用。
- 按照以下用户指南创建用户:创建 IAM 用户。
- 选择创建的用户。
- 选择安全凭据标签页。
- 在访问密钥部分中,点击创建访问密钥。
- 选择第三方服务作为使用情形。
- 点击下一步。
- 可选:添加说明标记。
- 点击创建访问密钥。
- 点击 Download CSV file(下载 CSV 文件),保存访问密钥和不公开的访问密钥以供日后使用。
- 点击完成。
- 选择权限标签页。
- 在权限政策部分中,点击添加权限。
- 选择添加权限。
- 选择直接附加政策。
- 搜索并选择 AmazonS3FullAccess 政策。
- 点击下一步。
- 点击添加权限。
创建 WAF Web ACL(访问控制列表)
如果您尚未设置 AWS WAF,则需要创建 WAF Web ACL(访问控制列表)。对于现有设置,您可以跳到下一个程序。
- 在 AWS 控制台中,搜索并选择 AWS WAF & Shield。
- 点击创建 Web ACL。
- 提供以下设置:
- 名称:为 ACL 命名(例如
my-waf-web-acl
)。 - 区域:选择您要应用 WAF 的区域。
- CloudWatch 指标:启用指标收集功能,以跟踪活动和触发的规则。
- 名称:为 ACL 命名(例如
- 创建完成后,选择要为其启用日志记录的 Web ACL。
如何配置 AWS WAF 日志记录
- 在 AWS WAF 控制台中,前往 Web ACL 的日志记录标签页。
- 点击启用日志记录。
- 选择 Amazon S3 作为日志的目标位置。
- 选择之前创建的 S3 存储桶来存储日志。
- 可选:配置用于整理日志的日志前缀(例如
waf-logs/
)。 - 点击保存。
验证 S3 存储分区的权限
确保 S3 存储桶拥有适当的权限,以便 AWS WAF 写入日志。
- 前往 S3 控制台。
- 选择将存储日志的存储桶。
在权限标签页中,添加以下存储分区政策,以允许 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/*" } ] }
- 点击保存。
设置 Feed
您可以通过两种不同的入口点在 Google SecOps 平台中设置 Feed:
- SIEM 设置 > Feed > 添加新 Feed
- 内容中心 > 内容包 > 开始
如何设置 AWS WAF Feed
- 点击 Amazon Cloud Platform 包。
- 找到 AWS WAF 日志类型。
在以下字段中指定值。
- 来源类型:Amazon SQS V2
- 队列名称:要从中读取数据的 SQS 队列名称
- S3 URI:存储桶 URI。
s3://your-log-bucket-name/
- 将
your-log-bucket-name
替换为您的 S3 存储桶的实际名称。
- 将
源删除选项:根据您的提取偏好设置选择删除选项。
文件存在时间上限:包含在过去指定天数内修改的文件。默认值为 180 天。
SQS 队列访问密钥 ID:一个包含 20 个字符的字母数字字符串形式的账号访问密钥。
SQS 队列私有访问密钥:一个包含 40 个字符的字母数字字符串形式的账号访问密钥。
高级选项
- Feed 名称:用于标识 Feed 的预填充值。
- 资源命名空间:与 Feed 关联的命名空间。
- 提取标签:应用于相应 Feed 中所有事件的标签。
点击创建 Feed。
如需详细了解如何为相应产品系列中的不同日志类型配置多个 Feed,请参阅按产品配置 Feed。
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 | 与 action 和 captchaResponse.responseCode 结合使用,以确定 security_result.action_details。 |
captchaResponse.responseCode | security_result.action_details | 与 action 和 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”,并将规则 ID 添加到 security_result.rule_labels 中,键为“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”,则提取终止规则操作并将其添加到 security_result.detection 字段,键为“terminatingRuleAction{index}”。 |
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 设置为“终止规则”。如果条件类型不为空,则会将其添加到 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 Application Firewall”。 | |
metadata.log_type | 设置为“AWS_WAF”。 | |
network.application_protocol | 设置为“HTTP”。 | |
metadata.event_type | 如果 httpRequest.headers 包含“host”或“Host”标头,则设置为“NETWORK_HTTP”。否则,请设置为“STATUS_UPDATE”。 |
需要更多帮助?从社区成员和 Google SecOps 专业人士那里获得解答。