为 AWS 启用 VM Threat Detection

本页介绍了如何设置和使用虚拟机威胁检测,以在 Amazon Elastic Compute Cloud (EC2) 虚拟机的永久性磁盘中扫描恶意软件

如需为 AWS 启用 VM Threat Detection,您需要在 AWS 平台上创建 AWS IAM 角色,在 Security Command Center 中启用适用于 AWS 的 VM Threat Detection,然后在 AWS 上部署 CloudFormation 模板。

准备工作

如需启用 VM Threat Detection 以便与 AWS 搭配使用,您需要拥有特定的 IAM 权限,并且 Security Command Center 必须与 AWS 相关联。

角色与权限

如需完成适用于 AWS 的虚拟机威胁检测的设置,您需要获得在Google Cloud 和 AWS 中都具有必要权限的角色。

Google Cloud 角色

Make sure that you have the following role or roles on the organization: Security Center Admin Editor (roles/securitycenter.adminEditor)

Check for the roles

  1. In the Google Cloud console, go to the IAM page.

    Go to IAM
  2. Select the organization.
  3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

  4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

Grant the roles

  1. In the Google Cloud console, go to the IAM page.

    进入 IAM
  2. 选择组织。
  3. 点击 授予访问权限
  4. 新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。

  5. 选择角色列表中,选择一个角色。
  6. 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
  7. 点击 Save(保存)。

AWS 角色

在 AWS 中,AWS 管理员用户必须创建您需要的 AWS 账号,以便启用扫描。

如需在 AWS 中为 VM Threat Detection 创建角色,请按照以下步骤操作:

  1. 使用 AWS 管理员用户账号,前往 AWS 管理控制台中的 IAM Roles 页面
  2. 服务或用例菜单中,选择 lambda
  3. 添加以下权限政策:
    • AmazonSSMManagedInstanceCore
    • AWSLambdaBasicExecutionRole
    • AWSLambdaVPCAccessExecutionRole
  4. 依次点击添加权限 > 创建内嵌政策,以创建新的权限政策:
    1. 打开以下页面并复制相应政策:适用于 AWS 漏洞评估和 VM Threat Detection 的角色政策
    2. JSON 编辑器中,粘贴相应政策。
    3. 为政策指定名称。
    4. 保存政策。
  5. 打开 Trust Relationships(信任关系)标签页。
  6. 粘贴以下 JSON 对象,将其添加到任何现有语句数组中:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "Statement1 or replace with a unique statementId",
          "Effect": "Allow",
          "Principal": {
            "Service": "cloudformation.amazonaws.com"
          },
          "Action": "sts:AssumeRole"
        }
      ]
    }
    
  7. 保存角色。

您稍后在 AWS 上安装 CloudFormation 模板时会分配此角色。

确认 Security Command Center 已连接到 AWS

虚拟机威胁检测功能需要访问您在创建 AWS 连接器时由 Cloud Asset Inventory 维护的 AWS 资源目录。

如果尚未建立连接,则您必须在为 AWS 启用虚拟机威胁检测时设置连接。

如需设置连接,请创建 AWS 连接器

在 Security Command Center 中为 AWS 启用 VM Threat Detection

必须在组织级 Google Cloud 启用适用于 AWS 的 VM Threat Detection。

控制台

  1. 在 Google Cloud 控制台中,前往 Virtual Machine Threat Detection Service Enablement 页面。

    前往“服务启用”页面

  2. 选择您的组织。

  3. 点击 Amazon Web Services(Amazon Web Services)标签页。

  4. 服务启用部分的状态字段中,选择启用

  5. AWS 连接器部分,验证状态是否显示为已添加 AWS 连接器

    如果状态显示为未添加 AWS 连接器,请点击添加 AWS 连接器。请先完成连接到 AWS 以进行配置和资源数据收集中的步骤,然后再执行下一步。

gcloud

gcloud scc manage services update 命令用于更新 Security Command Center 服务或模块的状态。

在使用下面的命令数据之前,请先进行以下替换:

  • ORGANIZATION_ID:组织的数字标识符
  • NEW_STATEENABLED 表示为 AWS 启用 VM Threat Detection;DISABLED 表示为 AWS 停用 VM Threat Detection

执行 gcloud scc manage services update 命令:

Linux、macOS 或 Cloud Shell

gcloud scc manage services update vm-threat-detection-aws \
    --organization=ORGANIZATION_ID \
    --enablement-state=NEW_STATE

Windows (PowerShell)

gcloud scc manage services update vm-threat-detection-aws `
    --organization=ORGANIZATION_ID `
    --enablement-state=NEW_STATE

Windows (cmd.exe)

gcloud scc manage services update vm-threat-detection-aws ^
    --organization=ORGANIZATION_ID ^
    --enablement-state=NEW_STATE

您应该会收到类似如下所示的响应:

effectiveEnablementState: ENABLED
intendedEnablementState: ENABLED
modules:
  MALWARE_DISK_SCAN_YARA_AWS:
    effectiveEnablementState: ENABLED
    intendedEnablementState: ENABLED
name: organizations/1234567890/locations/global/securityCenterServices/vm-threat-detection-aws
updateTime: '2025-03-21T18:45:52.033110465Z'

REST

Security Command Center Management API 的 organizations.locations.securityCenterServices.patch 方法用于更新 Security Command Center 服务或模块的状态。

在使用任何请求数据之前,请先进行以下替换:

  • QUOTA_PROJECT:用于结算和配额跟踪的项目 ID
  • ORGANIZATION_ID:组织的数字标识符
  • NEW_STATEENABLED 表示为 AWS 启用 VM Threat Detection;DISABLED 表示为 AWS 停用 VM Threat Detection

HTTP 方法和网址:

PATCH https://securitycentermanagement.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/securityCenterServices/vm-threat-detection-aws?updateMask=intendedEnablementState

请求 JSON 正文:

{
  "intendedEnablementState": "NEW_STATE"
}

如需发送您的请求,请展开以下选项之一:

您应该收到类似以下内容的 JSON 响应:

{
  "name": "organizations/1234567890/locations/global/securityCenterServices/vm-threat-detection-aws",
  "intendedEnablementState": "ENABLED",
  "effectiveEnablementState": "ENABLED",
  "modules": {
    "MALWARE_DISK_SCAN_YARA_AWS": {
      "intendedEnablementState": "ENABLED",
      "effectiveEnablementState": "ENABLED"
    }
  },
  "updateTime": "2025-03-21T18:45:52.033110465Z"
}

如果您已启用 AWS 漏洞评估服务,并已部署该功能的 CloudFormation 模板,则表示您已完成为 AWS 设置虚拟机威胁检测的设置。

否则,请等待 6 小时,然后执行下一个任务:下载 CloudFormation 模板。

下载 CloudFormation 模板

请在为 AWS 启用 VM Threat Detection 至少 6 小时后执行此任务。

  1. 在 Google Cloud 控制台中,前往 Virtual Machine Threat Detection Service Enablement 页面。

    前往“服务启用”页面

  2. 选择您的组织。

  3. 点击 Amazon Web Services(Amazon Web Services)标签页。

  4. 部署 CloudFormation 模板部分,点击下载 CloudFormation 模板。JSON 模板会下载到您的工作站。您需要在需要扫描的每个 AWS 账号中部署该模板。

部署 AWS CloudFormation 模板

请在创建 AWS 连接器至少 6 小时后执行以下步骤。

如需详细了解如何部署 CloudFormation 模板,请参阅 AWS 文档中的通过 CloudFormation 控制台创建堆栈

  1. 前往 AWS Management Console 中的 AWS CloudFormation 模板页面。
  2. 依次点击 Stacks > With new resources (standard)
  3. 创建堆栈页面上,依次选择选择现有模板上传模板文件,以上传 CloudFormation 模板。
  4. 上传完成后,输入一个具有唯一性的堆栈名称。请勿修改模板中的任何其他参数。
  5. 选择指定堆栈详情。系统会打开配置堆栈选项页面。
  6. 权限下,选择您之前创建的 AWS 角色。
  7. 如果系统提示,请选中确认对应的复选框。
  8. 点击提交以部署模板。堆栈需要几分钟才能开始运行。

部署状态会显示在 AWS 控制台中。如果 CloudFormation 模板部署失败,请参阅问题排查

扫描开始运行后,如果检测到任何威胁,系统会生成相应的发现结果,并在 Google Cloud 控制台中的 Security Command Center “发现结果”页面上显示这些结果。如需了解详情,请参阅在Google Cloud 控制台中查看发现结果

管理模块

本部分介绍了如何启用或停用模块以及查看其设置。

启用或停用模块

您启用或停用模块后,所做的更改最长可能需要 1 小时才会生效。

如需了解所有 VM Threat Detection 威胁发现结果及其生成模块,请参阅威胁发现结果

控制台

您可以通过 Google Cloud 控制台在组织级别启用或停用 VM Threat Detection 模块。

  1. 在 Google Cloud 控制台中,前往模块页面。

    进入“模块”

  2. 选择您的组织。

  3. 模块标签页的状态列中,选择要启用或停用的模块的当前状态,然后选择以下任一选项:

    • 启用:启用模块。
    • 停用:停用模块。

gcloud

gcloud scc manage services update 命令用于更新 Security Command Center 服务或模块的状态。

在使用下面的命令数据之前,请先进行以下替换:

  • ORGANIZATION_ID:组织的数字标识符
  • MODULE_NAME:要启用或停用的模块的名称,例如 MALWARE_DISK_SCAN_YARA_AWS。有效值仅包括支持 AWS 的威胁发现结果中的模块。
  • NEW_STATEENABLED 用于启用模块;DISABLED 用于停用模块

将以下内容保存在名为 request.json 的文件中:

{
  "MODULE_NAME": {
    "intendedEnablementState": "NEW_STATE"
  }
}

执行 gcloud scc manage services update 命令:

Linux、macOS 或 Cloud Shell

gcloud scc manage services update vm-threat-detection-aws \
    --organization=ORGANIZATION_ID \
    --enablement-state=ENABLED \  
    --module-config-file=request.json

Windows (PowerShell)

gcloud scc manage services update vm-threat-detection-aws `
    --organization=ORGANIZATION_ID `
    --enablement-state=ENABLED \  
    --module-config-file=request.json

Windows (cmd.exe)

gcloud scc manage services update vm-threat-detection-aws ^
    --organization=ORGANIZATION_ID ^
    --enablement-state=ENABLED \  
    --module-config-file=request.json

您应该会收到类似如下所示的响应:

effectiveEnablementState: ENABLED
intendedEnablementState: ENABLED
modules:
  MALWARE_DISK_SCAN_YARA_AWS:
    effectiveEnablementState: ENABLED
    intendedEnablementState: ENABLED
name: organizations/1234567890/locations/global/securityCenterServices/vm-threat-detection-aws
updateTime: '2025-03-21T18:45:52.033110465Z'

REST

Security Command Center Management API 的 organizations.locations.securityCenterServices.patch 方法用于更新 Security Command Center 服务或模块的状态。

在使用任何请求数据之前,请先进行以下替换:

  • QUOTA_PROJECT:用于结算和配额跟踪的项目 ID
  • ORGANIZATION_ID:组织的数字标识符
  • MODULE_NAME:要启用或停用的模块的名称,例如 MALWARE_DISK_SCAN_YARA_AWS。有效值仅包括支持 AWS 的威胁发现结果中的模块。
  • NEW_STATEENABLED 用于启用模块;DISABLED 用于停用模块

HTTP 方法和网址:

PATCH https://securitycentermanagement.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/securityCenterServices/vm-threat-detection-aws?updateMask=modules

请求 JSON 正文:

{
  "modules": {
    "MODULE_NAME": {
      "intendedEnablementState": "NEW_STATE"
    }
  }
}

如需发送您的请求,请展开以下选项之一:

您应该收到类似以下内容的 JSON 响应:

{
  "name": "organizations/1234567890/locations/global/securityCenterServices/vm-threat-detection-aws",
  "intendedEnablementState": "ENABLED",
  "effectiveEnablementState": "ENABLED",
  "modules": {
    "MALWARE_DISK_SCAN_YARA_AWS": {
      "intendedEnablementState": "ENABLED",
      "effectiveEnablementState": "ENABLED"
    }
  },
  "updateTime": "2025-03-21T18:45:52.033110465Z"
}

查看适用于 AWS 的 VM Threat Detection 模块的设置

如需了解所有 VM Threat Detection 威胁发现结果及其生成模块,请参阅威胁发现结果

控制台

借助 Google Cloud 控制台,您可以在组织级别查看 VM Threat Detection 模块的设置。

  1. 在 Google Cloud 控制台中,前往模块页面。

    进入“模块”

  2. 选择您的组织。

gcloud

gcloud scc manage services describe 命令用于获取 Security Command Center 服务或模块的状态。

在使用下面的命令数据之前,请先进行以下替换:

  • ORGANIZATION_ID:要获取其组织 ID 的组织的数字标识符

执行 gcloud scc manage services describe 命令:

Linux、macOS 或 Cloud Shell

gcloud scc manage services describe vm-threat-detection-aws \
    --organization=ORGANIZATION_ID

Windows (PowerShell)

gcloud scc manage services describe vm-threat-detection-aws `
    --organization=ORGANIZATION_ID

Windows (cmd.exe)

gcloud scc manage services describe vm-threat-detection-aws ^
    --organization=ORGANIZATION_ID

您应该会收到类似如下所示的响应:

effectiveEnablementState: ENABLED
intendedEnablementState: ENABLED
modules:
  MALWARE_DISK_SCAN_YARA_AWS:
    effectiveEnablementState: ENABLED
    intendedEnablementState: ENABLED
name: organizations/1234567890/locations/global/securityCenterServices/vm-threat-detection-aws
updateTime: '2025-03-21T18:45:52.033110465Z'

REST

Security Command Center Management API 的 organizations.locations.securityCenterServices.get 方法可获取 Security Command Center 服务或模块的状态。

在使用任何请求数据之前,请先进行以下替换:

  • QUOTA_PROJECT:用于结算和配额跟踪的项目 ID
  • ORGANIZATION_ID:要获取其组织 ID 的组织的数字标识符

HTTP 方法和网址:

GET https://securitycentermanagement.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/securityCenterServices/vm-threat-detection-aws

如需发送您的请求,请展开以下选项之一:

您应该收到类似以下内容的 JSON 响应:

{
  "name": "organizations/1234567890/locations/global/securityCenterServices/vm-threat-detection-aws",
  "intendedEnablementState": "ENABLED",
  "effectiveEnablementState": "ENABLED",
  "modules": {
    "MALWARE_DISK_SCAN_YARA_AWS": {
      "intendedEnablementState": "ENABLED",
      "effectiveEnablementState": "ENABLED"
    }
  },
  "updateTime": "2025-03-21T18:45:52.033110465Z"
}

问题排查

如果您已启用 VM Threat Detection 服务,但扫描未运行,请检查以下内容:

  • 检查 AWS 连接器是否已正确设置。
  • 确认 CloudFormation 模板堆栈已完全部署。其在 AWS 账号中的状态应为 CREATION_COMPLETE

后续步骤