收集 HashiCorp Vault 审核日志

支持的语言:

本文档介绍了如何使用 Bindplane 将 HashiCorp Vault 审核日志注入 Google Security Operations。

HashiCorp Vault 是一个 Secret Manager 和数据保护平台,提供安全存储、动态 Secret 生成、数据加密和基于身份的访问权限控制。Vault 会生成审核日志,记录对 Vault 的所有请求和响应,包括身份验证、Secret 访问和政策更改。这些审核日志可以使用 syslog 转发到 SIEM,以进行安全监控和合规性检查。

准备工作

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

  • Google SecOps 实例。
  • Windows Server 2016 或更高版本,或者安装了 systemd 的 Linux 主机。
  • Bindplane 代理与 HashiCorp Vault 服务器之间的网络连接。
  • 如果在代理后面运行,请确保防火墙端口根据 Bindplane 代理要求处于打开状态。
  • 对 HashiCorp Vault 服务器的特权访问权限(根令牌或足够的政策权限,可启用审核设备)。

获取 Bindplane 代理的 Google SecOps 凭证

如需向 Google SecOps 验证 Bindplane 代理,请选择以下方法之一:

  • 新部署:使用 Chronicle API(选项 1)。
  • 旧版部署:继续使用数据注入身份验证文件(方法 2),直到 Ingestion API 于 2027 年 7 月 20 日停用。
  1. 登录 Google Cloud 控制台,然后选择与您的 Google SecOps 实例关联的 Google Cloud 项目。
  2. 前往 IAM 和管理 > 服务账号。
  3. 点击创建服务账号。
  4. 提供以下配置详细信息:
    • 服务账号名称:输入账号的名称(例如 bindplane-ingest)。
    • 服务账号说明:输入说明(例如 Bindplane agent log ingestion)。
  5. 点击创建并继续。
  6. 在向此服务账号授予对项目的访问权限部分,点击选择角色,然后选择 Chronicle Editor。
  7. 点击继续,然后点击完成。
  8. 点击您创建的服务账号,然后前往密钥标签页。
  9. 依次点击添加密钥> 创建新密钥。
  10. 选择 JSON,然后点击创建。密钥文件会下载到您的计算机上。
  11. 将密钥文件另存为 Bindplane 收集器目录(在 Linux 上为 /opt/observiq-otel-collector/ingestion-auth.json,在 Windows 上为 C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json)中的 ingestion-auth.json,或更新 config.yaml 中的 creds_file_path 以与您保存密钥文件的路径相匹配。
  12. 前往 IAM 和管理 > 设置,然后复制项目编号。您在配置导出器时需要用到该名称。

方法 2:下载数据注入身份验证文件(旧版)

  1. 登录 Google SecOps 控制台。
  2. 前往 SIEM 设置> 收集代理。
  3. 下载数据注入身份验证文件。
  4. 将文件安全地保存在将安装 Bindplane 代理的系统上。

获取 Google SecOps 客户 ID

  1. 登录 Google SecOps 控制台。
  2. 依次前往 SIEM 设置 > 配置文件。
  3. 复制并保存组织详细信息部分中的客户 ID。

安装 Bindplane 代理

按照以下说明在 Windows 或 Linux 操作系统上安装 Bindplane 代理。

Windows 安装

  1. 以管理员身份打开命令提示符或 PowerShell。
  2. 运行以下命令:

    msiexec /i "[https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi](https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi)" /quiet
    
  3. 等待安装完成。

  4. 运行以下命令,验证安装是否成功:

    sc query observiq-otel-collector
    

该服务应显示为 RUNNING。

Linux 安装

  1. 打开具有 root 或 sudo 权限的终端。
  2. 运行以下命令:

    sudo sh -c "$(curl -fsSlL [https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh](https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh))" install_unix.sh
    
  3. 等待安装完成。

  4. 运行以下命令,验证安装是否成功:

    sudo systemctl status observiq-otel-collector
    

该服务应显示为 active (running)。

其他安装资源

如需了解其他安装选项和问题排查信息,请参阅 Bindplane 代理安装指南。

配置 Bindplane 代理以注入 syslog 并将其发送到 Google SecOps

找到配置文件

  • Linux:

    sudo nano /opt/observiq-otel-collector/config.yaml
    
  • Windows:

    notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
    

修改配置文件

  • 将 config.yaml 的全部内容替换为以下配置:

    receivers:
      tcplog:
        listen_address: "0.0.0.0:1514"
    
    exporters:
      chronicle/vault:
        protocol: https
        # Region of your instance, for example us, europe, asia-southeast1
        location: <LOCATION>
        # Project number of the Google Cloud project linked to the instance
        project: '<PROJECT_NUMBER>'
        compression: gzip
        creds_file_path: '/opt/observiq-otel-collector/ingestion-auth.json'
        customer_id: 'your-customer-id-here'
        endpoint: chronicle.googleapis.com
        log_type: HASHICORP
        raw_log_field: body
        ingestion_labels:
          env: production
    
    service:
      pipelines:
        logs/vault_to_chronicle:
          receivers:
            - tcplog
          exporters:
            - chronicle/vault
    

配置参数

替换以下占位符:

  • 接收器配置:

    • listen_address:要监听的 IP 地址和端口。使用 0.0.0.0 可监听所有接口。建议使用端口 1514,以避免在 Linux 上需要 root 权限。
  • 导出器配置:

    • creds_file_path:服务账号 JSON 密钥文件的完整路径(选项 1):
      • Linux:/opt/observiq-otel-collector/ingestion-auth.json
      • Windows:C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
    • customer_id:您的 Google SecOps 客户 ID。
    • location:将 <LOCATION> 替换为 Google SecOps 实例的区域(例如 us、europe 或 asia-southeast1)。导出器会使用此值作为 chronicle.googleapis.com 的前缀。如需查看完整列表,请参阅区域级端点。
    • project:将 <PROJECT_NUMBER> 替换为 IAM 和管理 > 设置中的项目编号。
    • endpoint:保持设置为 chronicle.googleapis.com。
    • ingestion_labels:YAML 格式的可选标签(例如 env: production)。

旧版提取 API

  • 如果您使用选项 2 中的数据注入身份验证文件,请将 exporters 代码块替换为以下内容。将 creds_file_path 设置为数据注入身份验证文件的路径,如果您的实例位于美国境外,请将 malachiteingestion-pa.googleapis.com 替换为您的区域端点(例如 europe-malachiteingestion-pa.googleapis.com)。

    exporters:
      chronicle/vault:
        compression: gzip
        creds_file_path: '/opt/observiq-otel-collector/ingestion-auth.json'
        customer_id: 'your-customer-id-here'
        endpoint: malachiteingestion-pa.googleapis.com
        log_type: HASHICORP
        raw_log_field: body
        ingestion_labels:
          env: production
    

保存配置文件

修改后,保存文件:

  • Linux:依次按 Ctrl+O、Enter 和 Ctrl+X
  • Windows:依次点击文件 > 保存

重启 Bindplane 代理以应用更改

如需在 Linux 中重启 Bindplane 代理,请执行以下操作:

  1. 运行以下命令:

    sudo systemctl restart observiq-otel-collector
    
  2. 验证服务是否正在运行:

    sudo systemctl status observiq-otel-collector
    
  3. 检查日志中是否存在错误:

    sudo journalctl -u observiq-otel-collector -f
    

如需在 Windows 中重启 Bindplane 代理,请执行以下操作:

  1. 请从下列选项中选择一项:

    • 以管理员身份运行命令提示符或 PowerShell:
    net stop observiq-otel-collector && net start observiq-otel-collector
    
    • 服务控制台:
      1. 按 Win+R,输入 services.msc,然后按 Enter 键。
      2. 找到 observIQ OpenTelemetry 收集器。
      3. 右键点击并选择重启。
  2. 验证服务是否正在运行:

    sc query observiq-otel-collector
    
  3. 检查日志中是否存在错误:

    type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
    

通过 syslog 配置 HashiCorp Vault 审核日志转发

Vault 审核设备会记录所有请求和响应。您可以启用 syslog 审核设备,将审核日志转发到 Bindplane 代理。

启用 syslog 审核设备

  1. 打开一个终端,该终端可以访问 Vault CLI 和有效的 Vault 令牌。
  2. 运行以下命令以启用 syslog 审核设备:

    vault audit enable syslog tag="vault" facility="AUTH"
    
  3. 验证审核设备是否已启用:

    vault audit list
    

输出应显示 syslog 审核设备为已启用。

配置 syslog 转发到 Bindplane 代理

启用 Vault syslog 审核设备后,配置系统 syslog 守护程序(rsyslog 或 syslog-ng),以将 Vault 审核日志转发到 Bindplane 代理。

选项 - rsyslog 配置

  1. 创建新的 rsyslog 配置文件:

    sudo nano /etc/rsyslog.d/50-vault-forward.conf
    
  2. 添加以下配置:

    # Forward Vault audit logs to Bindplane agent
    if $programname == 'vault' then @@BINDPLANE_IP:1514
    

    将 BINDPLANE_IP 替换为 Bindplane 代理主机的 IP 地址。

  3. 重启 rsyslog:

    sudo systemctl restart rsyslog
    

选项 - syslog-ng 配置

  1. 修改 syslog-ng 配置文件:

    sudo nano /etc/syslog-ng/conf.d/vault-forward.conf
    
  2. 添加以下配置:

    destination d_bindplane {
        network("BINDPLANE_IP" port(1514) transport("tcp"));
    };
    
    filter f_vault {
        program("vault");
    };
    
    log {
        source(s_src);
        filter(f_vault);
        destination(d_bindplane);
    };
    

    将 BINDPLANE_IP 替换为 Bindplane 代理主机的 IP 地址。

  3. 重启 syslog-ng:

    sudo systemctl restart syslog-ng
    

替代方案 - 使用日志转发器的基于文件的审核

如果不希望使用 syslog 审核,您可以启用文件审核设备并转发文件内容:

  1. 启用文件审核设备:

    vault audit enable file file_path=/var/log/vault/audit.log
    
  2. 配置 rsyslog 以监控和转发文件:

    sudo nano /etc/rsyslog.d/50-vault-file-forward.conf
    
    module(load="imfile")
    input(type="imfile"
        File="/var/log/vault/audit.log"
        Tag="vault-audit"
        Severity="info"
        Facility="auth")
    
    if $syslogtag == 'vault-audit' then @@BINDPLANE_IP:1514
    

    将 BINDPLANE_IP 替换为 Bindplane 代理主机的 IP 地址。

  3. 重启 rsyslog:

    sudo systemctl restart rsyslog
    

验证日志转发

  1. 执行 Vault 操作(例如,登录或读取 Secret):

    vault login token=<YOUR_TOKEN>
    
  2. 检查 Bindplane 代理日志,确认日志是否正在接收。

如需了解详情,请参阅 HashiCorp Vault 审核设备文档。

UDM 映射表

日志字段 UDM 映射 逻辑
auth.client_token network.session_id 从 auth.client_token(已哈希处理)获取的值。
auth.display_name principal.user.user_display_name 从 auth.display_name 获取的值。
auth.metadata.role_name principal.user.attribute.roles.name 值取自 auth.metadata.role_name。
auth.policies principal.user.attribute.permissions.name 从 auth.policies 数组中获取的值。
auth.token_type additional.fields 从 auth.token_type 中获取值,并使用键 token_type 添加该值。
request.id metadata.product_log_id 从 request.id 获取的值。
request.operation metadata.product_event_type 从 request.operation 获取的值。
request.path target.resource.name 从 request.path 获取的值。
request.remote_address principal.ip 从 request.remote_address 获取的值。
request.namespace.id target.namespace 从 request.namespace.id 获取的值。
response.auth.client_token network.session_id 从响应 client_token 中提取的值(已进行哈希处理)。
type metadata.product_event_type 附加到操作(例如 request 或 response)。
time metadata.event_timestamp 解析为 RFC 3339 时间戳。
error security_result.description 如果存在,则从 error 中获取值。
metadata.vendor_name 设置为 HashiCorp。
metadata.product_name 设置为保险柜。
metadata.event_type 对于密钥操作,设置为 USER_RESOURCE_ACCESS;对于身份验证操作,设置为 USER_LOGIN;否则设置为 GENERIC_EVENT。
response.auth.metadata.username event.idm.read_only_udm.target.user.userid 从更新日志映射
appname event.idm.read_only_udm.target.application 从更新日志映射
priority event.idm.read_only_udm.security_result.priority_details 从更新日志映射
proc_id event.idm.read_only_udm.observer.process.pid 从更新日志映射
auth.policies event.idm.read_only_udm.additional.fields 从更新日志映射
auth.token_policies event.idm.read_only_udm.additional.fields 从更新日志映射
request.policy_override event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.admin_password event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.admin_token event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.admin_user event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.certificate event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.check_url event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.keystore event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.keystore_password event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
response.data.private_key event.idm.read_only_udm.target.resource.attribute.labels 从更新日志映射
type event.idm.read_only_udm.additional.fields 从更新日志映射
auth.identity_policies event.idm.read_only_udm.additional.fields 从更新日志映射
request.data event.idm.read_only_udm.additional.fields 从更新日志映射
facility event.idm.read_only_udm.additional.fields 从更新日志映射
task event.idm.read_only_udm.additional.fields 从更新日志映射
jsonPayload.auth.policy_results.granting_policies.type", "jsonPayload.auth.policy_results.granting_policies.name", and "jsonPayload.auth.policy_results.granting_policies.namespace_id additional.fields 从更新日志映射
jsonPayload.request.namespace.id target.namespace 从更新日志映射
jsonPayload.cos.googleapis.com/container_id", "jsonPayload.cos.googleapis.com/container_name", "jsonPayload.cos.googleapis.com/stream additional.fields 从更新日志映射
resource.labels.instance_id principal.resource.product_object_id 从更新日志映射
principal.resource.attribute.cloud.availability_zone resource.labels.zone 从更新日志映射
logName security_result.category_details 从更新日志映射
resource.labels.namespace_name target.namespace 从更新日志映射
resource.labels.pod_name", "resource.labels.container_name additional.fields 从更新日志映射
resource.labels.project_id target.cloud.project.name 从更新日志映射
resource.labels.location target.location.name 从更新日志映射
insertId metadata.product_log_id 从更新日志映射
labels.k8s-pod/app_kubernetes_io/instance", "labels.k8s-pod/app_kubernetes_io/name", "labels.k8s-pod/component", "labels.k8s-pod/helm_sh/chart", "labels.k8s-pod/controller-revision-hash", "labels.k8s-pod/vault-initialized", "labels.k8s-pod/vault-version", "labels.k8s-pod/vault-sealed", "labels.k8s-pod/vault-perf-standby", and "labels.k8s-pod/vault-active target.resource.attribute.labels 从更新日志映射
labels.compute.googleapis.com/resource_name target.resource.name 从更新日志映射
status network.http.response_code 从更新日志映射
runner principal.user.userid 从更新日志映射
job_id", "job_status additional.fields 从更新日志映射
host observer.hostname 从更新日志映射
cluster observer.resource.name 从更新日志映射
cluster observer.resource.resource_type 从更新日志映射

更新日志

查看此解析器的更新日志

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