收集 AWS Security Hub 日志

支持的语言:

本文档介绍了如何将 AWS Security Hub 日志注入到 Google Security Operations。AWS Security Hub 可全面查看各个 AWS 账号中的安全提醒和发现结果。通过将这些发现结果发送到 Google SecOps,您可以使用 Google SecOps 功能来增强监控和威胁检测。

准备工作

确保您满足以下前提条件:

  • Google SecOps 实例
  • 对 AWS 的特权访问权限

配置 AWS IAM 和 S3

  1. 按照以下用户指南创建 Amazon S3 存储桶创建存储桶
  2. 保存相应存储桶的名称区域以备后用。
  3. 按照以下用户指南创建用户:创建 IAM 用户
  4. 选择创建的用户
  5. 选择安全凭据标签页。
  6. 访问密钥部分中,点击创建访问密钥
  7. 选择第三方服务作为使用情形
  8. 点击下一步
  9. 可选:添加说明标记。
  10. 点击创建访问密钥
  11. 点击 Download CSV file(下载 CSV 文件),保存访问密钥不公开的访问密钥以供日后使用。
  12. 点击完成
  13. 选择权限标签页。
  14. 权限政策部分中,点击添加权限
  15. 选择添加权限
  16. 选择直接附加政策
  17. 搜索并选择 AmazonS3FullAccess 政策。
  18. 点击下一步
  19. 点击添加权限

创建 Lambda 函数

  1. 登录 AWS Management Console
  2. 前往 Lambda
  3. 点击创建函数,然后选择从头开始编写
  4. 为函数命名,例如 SecurityHubToS3
  5. 为运行时选择 Python 3.x
  6. 输入以下 Lambda 代码,该代码可从 EventBridge 获取检测结果并将其写入您的 S3 存储桶:

    import json
    import boto3
    from datetime import datetime
    
    # Initialize the S3 client
    s3_client = boto3.client('s3')
    
    # S3 bucket where findings will be stored
    bucket_name = 'aws-security-hub-findings-stream'
    
    def lambda_handler(event, context):
       # Extract Security Hub findings from the event
       findings = event['detail']['findings']
    
       # Generate a timestamp for the file name to avoid overwriting
       timestamp = datetime.now().strftime('%Y-%m-%dT%H-%M-%S')
    
       # Generate the S3 object key (file name) based on the timestamp
       object_key = f"security_hub_findings_{timestamp}.json"
    
       # Convert findings to JSON format
       findings_json = json.dumps(findings)
    
       # Upload the findings to S3
       try:
          response = s3_client.put_object(
                Bucket=bucket_name,
                Key=object_key,
                Body=findings_json,
                ContentType='application/json'
          )
          print(f"Successfully uploaded findings to S3: {response}")
       except Exception as e:
          print(f"Error uploading findings to S3: {e}")
          raise e
    
       return {
          'statusCode': 200,
          'body': json.dumps('Successfully processed findings')
       }
    
  7. 通过向 Lambda 函数添加具有以下政策的 IAM 角色来设置 Lambda 的权限:

    {
       "Version": "2012-10-17",
       "Statement": [
          {
                "Effect": "Allow",
                "Action": [
                   "s3:PutObject"
                ],
                "Resource": "arn:aws:s3:::aws-security-hub-findings-stream/*"
          }
       ]
    }
    

如何配置 AWS Security Hub 以通过 EventBridge 转发发现结果

  1. 登录 AWS Management Console
  2. 在搜索栏中,输入并从服务列表中选择 Security Hub
  3. 点击设置
  4. 集成部分下,找到 EventBridge,然后点击启用
  5. 在搜索栏中,输入并从服务列表中选择 EventBridge
  6. 在 EventBridge 控制台中,依次点击规则 > 创建规则
  7. 提供以下规则配置:
    1. 规则名称:为规则提供一个描述性名称,例如 SendSecurityHubFindingsToS3
    2. 事件源:选择 AWS 服务
    3. 服务名称:选择 Security Hub
    4. 事件类型:选择 Security Hub 检测结果
    5. 设置目标:选择 Lambda 函数
    6. 选择您刚刚创建的 Lambda 函数 (SecurityHubToS3)。
  8. 点击创建

设置 Feed

您可以通过两种不同的入口点在 Google SecOps 平台中设置 Feed:

  • SIEM 设置 > Feed
  • 内容中心 > 内容包

通过“SIEM 设置”>“Feed”设置 Feed

如需为相应产品系列中的不同日志类型配置多个 Feed,请参阅配置多个 Feed

如需配置单个 Feed,请按以下步骤操作:

  1. 依次前往 SIEM 设置> Feed
  2. 点击添加新 Feed
  3. 在下一页上,点击配置单个 Feed
  4. 信息流名称字段中,输入信息流的名称,例如 AWS Security Hub 日志
  5. 选择 Amazon S3 作为来源类型
  6. 选择 AWS Security Hub 作为日志类型
  7. 点击下一步
  8. 为以下输入参数指定值:

    • 区域:Amazon S3 存储桶所在的区域。
    • S3 URI:存储桶 URI。
      • s3://your-log-bucket-name/
        • your-log-bucket-name 替换为您的 S3 存储桶的实际名称。
    • URI is a:根据您的存储桶结构,选择目录目录(包括子目录)
    • 源删除选项:根据您的提取偏好设置选择删除选项。

    • 访问密钥 ID:有权从 S3 存储桶读取数据的用户的访问密钥。

    • 私有访问密钥:具有从 S3 存储桶读取权限的用户的私有密钥。

    • 资源命名空间资源命名空间

    • 注入标签:要应用于此 Feed 中事件的标签。

  9. 点击下一步

  10. 最终确定界面中查看新的 Feed 配置,然后点击提交

设置来自内容中心的 Feed

为以下字段指定值:

  • 区域:Amazon S3 存储桶所在的区域。
  • S3 URI:存储桶 URI。
    • s3://your-log-bucket-name/
      • your-log-bucket-name 替换为您的 S3 存储桶的实际名称。
  • URI is a:根据您的存储桶结构,选择目录目录(包括子目录)
  • 源删除选项:根据您的提取偏好设置选择删除选项。
  • 访问密钥 ID:有权从 S3 存储桶读取数据的用户的访问密钥。

  • 私有访问密钥:具有从 S3 存储桶读取权限的用户的私有密钥。

高级选项

  • Feed 名称:用于标识 Feed 的预填充值。
  • 来源类型:用于将日志收集到 Google SecOps 中的方法。
  • 资产命名空间与 Feed 关联的命名空间
  • 提取标签:应用于相应 Feed 中所有事件的标签。

UDM 映射表

日志字段 UDM 映射 逻辑
account principal.group.product_object_id 与发现关联的 AWS 账号 ID。
configurationItem.ARN target.resource.id 配置项的 Amazon 资源名称 (ARN)。
configurationItem.awsAccountId principal.user.userid 配置项的 AWS 账号 ID。
configurationItem.awsRegion target.asset.location.country_or_region 配置项的 AWS 区域。
configurationItem.configuration.complianceType security_result.summary 配置项的合规性类型。
configurationItem.configuration.configRuleList[].complianceType security_result.summary 每条配置规则的合规性状态。
configurationItem.configuration.configRuleList[].configRuleArn security_result.rule_id AWS Config 规则的 ARN。
configurationItem.configuration.configRuleList[].configRuleId security_result.about.labels.configRuleId AWS Config 规则的 ID。
configurationItem.configuration.configRuleList[].configRuleName security_result.rule_name AWS Config 规则的名称。
configurationItem.configuration.privateIpAddress target.ip 配置项的专用 IP 地址。
configurationItem.configuration.publicIpAddress target.ip 配置项的公共 IP 地址。
configurationItem.configurationItemCaptureTime target.asset.attribute.creation_time 配置项的捕获时间,已转换为时间戳。
configurationItem.configurationItemStatus target.asset.attribute.labels.Configuration Item Status 配置项的状态。
configurationItem.relationships[].resourceId target.asset.attribute.cloud.vpc.id 相关资源的资源 ID,如果与 vpc 匹配,则用于 VPC ID。
configurationItem.resourceId target.resource.id 配置项的资源 ID。
configurationItem.resourceName target.resource.name 资源的名称。
configurationItem.resourceType target.resource.resource_subtype 配置项的资源类型。
configurationItem.tags.Contact principal.user.user_display_nameprincipal.user.email_addresses 从标记中提取的联系人详细信息,已解析为电子邮件地址和用户名。
configurationItem.tags.OS/configurationItem.tags.Os target.asset.platform_software.platform 来自标记的操作系统,如果为 WindowsLinux,则映射到平台。
configurationItemDiff.changeType metadata.event_type 更改类型,映射到 RESOURCE_WRITTEN 或 RESOURCE_CREATION。
detail.accountId principal.group.product_object_id 与发现关联的 AWS 账号 ID。
detail.actionDescription detail.actionName detail.description sec_result.description 调查结果的说明。
detail.findings[].AwsAccountId principal.group.product_object_id 与发现关联的 AWS 账号 ID。
detail.findings[].CompanyName detail.findings[].CreatedAt detail.findings[].Description sec_result.description 调查结果的说明。
detail.findings[].FindingProviderFields.Severity.Label sec_result.severity 发现结果的严重程度标签,会转换为大写。
detail.findings[].FindingProviderFields.Types[] detail.findings[].FirstObservedAt detail.findings[].GeneratorId detail.findings[].Id detail.findings[].LastObservedAt detail.findings[].ProductArn detail.findings[].ProductFields. 如下所示 用于其他字段、正文和目标信息的各种字段。
detail.findings[].ProductName detail.findings[].RecordState detail.findings[].Region target.location.name 发现结果的 AWS 区域。
detail.findings[].Resources[].Details. 如下所示 与发现结果相关的资源的详细信息。
detail.findings[].Resources[].Id target.resource.product_object_id 资源的 ID。
detail.findings[].Resources[].Partition detail.findings[].Resources[].Region target.location.name 资源的 AWS 区域。
detail.findings[].Resources[].Tags detail.findings[].Resources[].Type target.resource.resource_typetarget.resource.resource_subtypemetadata.event_type 用于资源类型、子类型和事件类型映射的资源类型。
detail.findings[].Sample detail.findings[].SchemaVersion detail.findings[].Severity.Label detail.findings[].SourceUrl detail.findings[].Title sec_result.summary 调查结果的标题。
detail.findings[].Types[] detail.findings[].UpdatedAt detail.findings[].Workflow.Status detail.findings[].WorkflowState detail-type metadata.product_event_type 事件的详细类型。
id metadata.product_log_id 活动的 ID。
region target.location.name 活动的 AWS 区域。
resources[] source time version(解析器逻辑) metadata.event_timestamp 原始日志条目中的创建时间,用作事件时间戳。
(解析器逻辑) metadata.log_type 设置为 AWS_SECURITY_HUB
(解析器逻辑) metadata.product_name 设置为 AWS Security Hub
(解析器逻辑) metadata.vendor_name 设置为 AMAZON
(解析器逻辑) target.asset.attribute.cloud.environment 设置为 AMAZON_WEB_SERVICES
(解析器逻辑) metadata.event_type 如果未从 Resources[].TypeconfigurationItemDiff.changeType 进行映射,则默认设置为 USER_RESOURCE_ACCESS。如果存在 configurationItems 且未设置其他事件类型,则设置为 STATUS_UPDATE。如果存在 configurationItemconfigurationItems,且状态为 OKResourceDiscovered,则设置为 RESOURCE_READ。如果存在 configurationItemconfigurationItems 且状态为 ResourceDeleted,则设置为 RESOURCE_DELETION
(解析器逻辑) metadata.description 如果存在 detail.findings[].ProductFields.aws/guardduty/service/serviceName,则设置为 guardduty
(解析器逻辑) target.asset.attribute.cloud.vpc.resource_type 如果 configurationItems.relationships[].resourceIdvpc 匹配,则设置为 VPC_NETWORK
(解析器逻辑) target.resource.resource_type 如果存在 configurationItemconfigurationItems,则设置为 VIRTUAL_MACHINE。如果没有设置其他资源类型,则设置为 UNSPECIFIED
(解析器逻辑) target.asset.platform_software.platform 根据 configurationItem 的消息中是否存在 Windows(Linux|LINUX),将此属性设置为 WINDOWSLINUX。对于 configurationItems,系统会根据 configItem.tags.OSconfigItem.tags.Os 进行设置。
(解析器逻辑) disambiguation_key 当单个日志条目生成多个事件时添加。

需要更多帮助?从社区成员和 Google SecOps 专业人士那里获得解答。