detecting-cloud-threats-with-guardduty

本 skill 教导安全团队如何部署和运营 Amazon GuardDuty,实现对 AWS 账户和工作负载的持续威胁检测。内容涵盖为 S3、EKS、EC2 运行时监控和 Lambda 启用保护计划、解读发现严重级别,以及使用 EventBridge 和 Lambda 构建自动化响应工作流。

9 stars

Best use case

detecting-cloud-threats-with-guardduty is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

本 skill 教导安全团队如何部署和运营 Amazon GuardDuty,实现对 AWS 账户和工作负载的持续威胁检测。内容涵盖为 S3、EKS、EC2 运行时监控和 Lambda 启用保护计划、解读发现严重级别,以及使用 EventBridge 和 Lambda 构建自动化响应工作流。

Teams using detecting-cloud-threats-with-guardduty should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/detecting-cloud-threats-with-guardduty/SKILL.md --create-dirs "https://raw.githubusercontent.com/killvxk/cybersecurity-skills-zh/main/skills/detecting-cloud-threats-with-guardduty/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/detecting-cloud-threats-with-guardduty/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How detecting-cloud-threats-with-guardduty Compares

Feature / Agentdetecting-cloud-threats-with-guarddutyStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

本 skill 教导安全团队如何部署和运营 Amazon GuardDuty,实现对 AWS 账户和工作负载的持续威胁检测。内容涵盖为 S3、EKS、EC2 运行时监控和 Lambda 启用保护计划、解读发现严重级别,以及使用 EventBridge 和 Lambda 构建自动化响应工作流。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 使用 GuardDuty 检测云威胁

## 适用场景

- 为新建或现有 AWS 账户建立持续威胁检测时
- 调查与被入侵实例、凭据滥用或数据泄露相关的 GuardDuty 发现时
- 构建由 GuardDuty 发现触发的自动化事件响应手册时
- 将威胁检测范围扩展至运行在 EKS、ECS 或 Fargate 上的容器工作负载时
- 为附加到可疑 EC2 实例的 EBS 卷启用恶意软件扫描时

**不适用于**:Azure 或 GCP 的威胁检测(请参阅 securing-azure-with-microsoft-defender 或 auditing-gcp-security-posture)、静态代码分析,或合规态势监控(请参阅 implementing-aws-security-hub)。

## 前置条件

- 具有 GuardDuty 管理员权限(guardduty:*)的 AWS 账户
- 启用 AWS CloudTrail、VPC Flow Logs 和 DNS 查询日志(GuardDuty 自动使用这些数据源)
- 若需跨多账户环境部署 GuardDuty,须配置 AWS Organizations
- 配置 EventBridge 和 Lambda 用于自动化响应工作流

## 工作流程

### 步骤 1:启用 GuardDuty 及保护计划

使用委派管理员账户在组织层面激活 GuardDuty,并启用所有保护计划,包括 S3 Protection、EKS Audit Log Monitoring、Runtime Monitoring、Malware Protection、RDS Login Activity 和 Lambda Network Activity Monitoring。

```bash
# 启用 GuardDuty 作为组织委派管理员
aws guardduty create-detector \
  --enable \
  --finding-publishing-frequency FIFTEEN_MINUTES \
  --data-sources '{
    "S3Logs": {"Enable": true},
    "Kubernetes": {"AuditLogs": {"Enable": true}},
    "MalwareProtection": {"ScanEc2InstanceWithFindings": {"EbsVolumes": true}}
  }'

# 为 EC2 和 ECS 启用 Runtime Monitoring
aws guardduty update-detector \
  --detector-id <detector-id> \
  --features '[
    {"Name": "RUNTIME_MONITORING", "Status": "ENABLED",
     "AdditionalConfiguration": [
       {"Name": "ECS_FARGATE_AGENT_MANAGEMENT", "Status": "ENABLED"},
       {"Name": "EC2_AGENT_MANAGEMENT", "Status": "ENABLED"}
     ]}
  ]'

# 为多账户环境指定委派管理员
aws guardduty enable-organization-admin-account \
  --admin-account-id 111122223333
```

### 步骤 2:配置多账户聚合

自动注册所有组织成员账户,并将发现导出至中央 S3 存储桶,用于数据留存和 SIEM 接入。

```bash
# 为所有组织成员自动启用 GuardDuty
aws guardduty update-organization-configuration \
  --detector-id <detector-id> \
  --auto-enable-organization-members ALL \
  --features '[
    {"Name": "S3_DATA_EVENTS", "AutoEnable": "ALL"},
    {"Name": "EKS_AUDIT_LOGS", "AutoEnable": "ALL"},
    {"Name": "RUNTIME_MONITORING", "AutoEnable": "ALL"}
  ]'

# 配置将发现导出至 S3
aws guardduty create-publishing-destination \
  --detector-id <detector-id> \
  --destination-type S3 \
  --destination-properties '{
    "DestinationArn": "arn:aws:s3:::guardduty-findings-centralized",
    "KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/key-id"
  }'
```

### 步骤 3:解读发现类型和严重级别

GuardDuty 将发现分为四个严重级别:严重(Critical)、高(High)、中(Medium)和低(Low)。每种发现类型遵循 ThreatPurpose:ResourceType/ThreatName 格式。扩展威胁检测(Extended Threat Detection)生成跨时间关联多个事件的攻击序列发现。

主要发现类别:
- **Recon(侦察)**:端口扫描、API 枚举(例如 Recon:EC2/PortProbeUnprotectedPort)
- **UnauthorizedAccess(未授权访问)**:凭据滥用、来自异常位置的控制台登录
- **CryptoCurrency(加密货币)**:实例上检测到挖矿活动(例如 CryptoCurrency:EC2/BitcoinTool.B)
- **Impact(影响)**:资源劫持、数据销毁企图
- **AttackSequence(攻击序列)**:关联从初始访问到横向移动再到影响的多阶段攻击(严重级别)

### 步骤 4:使用 EventBridge 构建自动化响应

创建 EventBridge 规则,将 GuardDuty 发现路由至 Lambda 函数执行自动遏制操作,例如隔离被入侵的 EC2 实例、撤销 IAM 凭据或封锁恶意 IP 地址。

```bash
# 针对高危/严重 GuardDuty 发现创建 EventBridge 规则
aws events put-rule \
  --name GuardDutyHighSeverity \
  --event-pattern '{
    "source": ["aws.guardduty"],
    "detail-type": ["GuardDuty Finding"],
    "detail": {
      "severity": [{"numeric": [">=", 7]}]
    }
  }'

# 设置自动修复 Lambda 函数为目标
aws events put-targets \
  --rule GuardDutyHighSeverity \
  --targets '[{
    "Id": "AutoRemediateTarget",
    "Arn": "arn:aws:lambda:us-east-1:123456789012:function/guardduty-auto-remediate"
  }]'
```

隔离被入侵 EC2 实例的自动修复 Lambda 示例:

```python
import boto3

def lambda_handler(event, context):
    finding = event['detail']
    finding_type = finding['type']
    severity = finding['severity']

    if finding_type.startswith('UnauthorizedAccess:EC2') and severity >= 7:
        instance_id = finding['resource']['instanceDetails']['instanceId']
        ec2 = boto3.client('ec2')

        # 创建隔离安全组(无入站/出站规则)
        vpc_id = finding['resource']['instanceDetails']['networkInterfaces'][0]['vpcId']
        isolation_sg = ec2.create_security_group(
            GroupName=f'isolation-{instance_id}',
            Description='GuardDuty auto-isolation',
            VpcId=vpc_id
        )

        # 将所有安全组替换为隔离安全组
        ec2.modify_instance_attribute(
            InstanceId=instance_id,
            Groups=[isolation_sg['GroupId']]
        )

        # 为实例添加标签以便调查
        ec2.create_tags(
            Resources=[instance_id],
            Tags=[{'Key': 'SecurityStatus', 'Value': 'ISOLATED'},
                  {'Key': 'GuardDutyFinding', 'Value': finding_type}]
        )

        return {'status': 'isolated', 'instance': instance_id}
```

### 步骤 5:调查扩展威胁检测攻击序列

审查关联 EC2、ECS 和 EKS 多个信号的严重级别攻击序列发现。这些发现代表多阶段攻击,例如通过被入侵凭据初始访问,继而持久化、横向移动和挖矿。

```bash
# 列出严重攻击序列发现
aws guardduty list-findings \
  --detector-id <detector-id> \
  --finding-criteria '{
    "Criterion": {
      "severity": {"Gte": 9},
      "type": {"Eq": ["AttackSequence:EC2/CompromisedInstanceGroup",
                       "AttackSequence:ECS/CompromisedCluster",
                       "AttackSequence:EKS/CompromisedCluster"]}
    }
  }'

# 获取包含攻击序列时间线的完整发现详情
aws guardduty get-findings \
  --detector-id <detector-id> \
  --finding-ids <finding-id>
```

### 步骤 6:与 Security Hub 和 SIEM 集成

将 GuardDuty 发现转发至 AWS Security Hub 进行集中聚合,并通过 S3 导出或 Amazon Security Lake 传送至外部 SIEM 平台,用于长期留存和跨来源关联分析。

```bash
# 验证 GuardDuty 与 Security Hub 的集成
aws securityhub get-enabled-standards

# 启用 Amazon Security Lake 并将 GuardDuty 设为数据源
aws securitylake create-data-lake \
  --configurations '[{
    "region": "us-east-1",
    "lifecycleConfiguration": {
      "expiration": {"days": 365}
    }
  }]'
```

## 核心概念

| 术语 | 定义 |
|------|------|
| 扩展威胁检测(Extended Threat Detection) | GuardDuty 功能,跨时间关联多个信号以检测多阶段攻击,生成严重级别的攻击序列发现 |
| Runtime Monitoring(运行时监控) | 在 EC2 实例、ECS 任务和 EKS Pod 上部署安全 Agent,在操作系统层面检测运行时威胁的保护计划 |
| 发现严重级别(Finding Severity) | 四级分类(低、中、高、严重),严重级别表示需要立即响应的已确认多阶段攻击 |
| Malware Protection(恶意软件保护) | 由可疑 EC2 行为触发的按需和自动 EBS 卷扫描,无需安装 Agent 即可检测恶意软件 |
| 委派管理员(Delegated Administrator) | 被指定管理 AWS 组织内所有账户 GuardDuty 的组织成员账户 |
| 抑制规则(Suppression Rule) | 自动归档匹配特定条件的发现的过滤器,用于减少已知无害活动产生的噪音 |
| 威胁情报(Threat Intelligence) | GuardDuty 用于识别与已知恶意基础设施通信的 IP 信誉列表和域名威胁订阅源 |

## 工具与系统

- **Amazon GuardDuty**:核心威胁检测服务,分析 CloudTrail、VPC Flow Logs、DNS 日志和运行时遥测数据
- **Amazon EventBridge**:无服务器事件总线,将 GuardDuty 发现路由至自动化响应目标
- **AWS Security Hub**:集中式安全发现聚合平台,支持自动化修复工作流
- **Amazon Security Lake**:基于 OCSF 规范的数据湖,用于长期安全日志留存和跨服务关联分析
- **Amazon Detective**:基于图形的调查服务,可视化 GuardDuty 发现、资源和 API 活动之间的关系

## 常见场景

### 场景:在 ECS 集群上检测到加密货币挖矿

**场景背景**:GuardDuty 生成针对 ECS Fargate 任务的 CryptoCurrency:Runtime/BitcoinTool.B 高危发现。Runtime Monitoring 检测到容器内执行了挖矿程序。

**方法**:
1. 查看发现详情以确定 ECS 集群、任务定义和容器镜像
2. 立即停止受影响的 ECS 任务,并在 ECR 中隔离容器镜像
3. 检查 CloudTrail 中的 ecs:RegisterTaskDefinition 和 ecs:RunTask 调用,以识别是谁部署了恶意镜像
4. 使用 ECR 增强扫描对 Docker 镜像进行扫描,以识别嵌入的挖矿程序
5. 检查用于推送镜像的 IAM 凭据,并撤销被入侵的访问权限
6. 更新 ECR 镜像扫描策略,阻止包含已知挖矿签名的镜像

**常见陷阱**:在未保留容器镜像的情况下停止任务会丢失取证证据。未能追溯到 RegisterTaskDefinition API 调用则会遗漏初始入侵向量。

## 输出格式

```
GuardDuty 威胁检测摘要
====================================
账户: 123456789012(生产环境)
区域: us-east-1
时间段: 2025-02-01 至 2025-02-23

严重发现(需立即处置):
[CRIT-001] AttackSequence:EC2/CompromisedInstanceGroup
  - 实例: i-0abc123def, i-0def456abc
  - 攻击链: 凭据窃取 -> 持久化 -> 加密货币挖矿
  - 首次信号: 2025-02-15T08:23:00Z
  - 持续时间: 跨 3 个阶段约 4 小时
  - 状态: 已通过 Lambda 自动隔离

高危发现:
[HIGH-001] UnauthorizedAccess:IAMUser/MaliciousIPCaller
  - 主体: arn:aws:iam::123456789012:user/ci-deploy
  - 来源 IP: 198.51.100.42(Tor 出口节点)
  - API 调用: 向 ec2:RunInstances 发起 47 次调用
  - 状态: 访问密钥已停用

[HIGH-002] CryptoCurrency:Runtime/BitcoinTool.B
  - 资源: ECS 任务 arn:aws:ecs:us-east-1:123456789012:task/cluster/task-id
  - 镜像: 123456789012.dkr.ecr.us-east-1.amazonaws.com/app:v2.1
  - 进程: /tmp/.hidden/xmrig --pool stratum+tcp://pool.example.com:3333
  - 状态: 任务已停止,镜像已隔离

统计数据:
  总发现数: 23
  严重: 1 | 高: 3 | 中: 8 | 低: 11
  自动修复: 4
  待调查: 2
```

Related Skills

securing-kubernetes-on-cloud

9
from killvxk/cybersecurity-skills-zh

本技能涵盖通过实施 Pod 安全标准(Pod Security Standards)、网络策略、工作负载身份、RBAC 权限控制、镜像准入控制和运行时安全监控,对 EKS、AKS 和 GKE 上的托管 Kubernetes 集群进行加固。涉及云平台特定安全功能,包括 EKS 的 IRSA、GKE 的工作负载身份(Workload Identity)以及 AKS 的托管身份(Managed Identity)。

performing-dark-web-monitoring-for-threats

9
from killvxk/cybersecurity-skills-zh

暗网威胁监控涉及系统性扫描 Tor 隐藏服务、地下论坛、粘贴站点和暗网市场,以识别针对组织的威胁,包括泄露凭据、数据泄露、威胁行为者讨论、漏洞利用工具和预谋攻击。

performing-cloud-storage-forensic-acquisition

9
from killvxk/cybersecurity-skills-zh

通过收集 API 远程数据和端点设备本地同步客户端制品,对 Google Drive、OneDrive、Dropbox 和 Box 等云存储服务执行取证获取和分析。

performing-cloud-penetration-testing

9
from killvxk/cybersecurity-skills-zh

对 AWS、Azure 和 GCP 云环境执行授权渗透测试,识别 IAM 错误配置、暴露的存储桶、过度宽松的安全组、 无服务器函数漏洞以及从初始访问到账户沦陷的云特定攻击路径。测试人员使用云原生工具及 Pacu、 ScoutSuite 等专用框架枚举并利用云基础设施。适用于云渗透测试、AWS 安全评估、Azure 渗透测试 或云基础设施安全测试等请求场景。

performing-cloud-penetration-testing-with-pacu

9
from killvxk/cybersecurity-skills-zh

使用开源 AWS 利用框架 Pacu 执行已授权的 AWS 渗透测试,枚举 IAM 配置、发现权限提升路径、测试凭据收集,并通过系统化的攻击模拟验证安全控制。

performing-cloud-native-forensics-with-falco

9
from killvxk/cybersecurity-skills-zh

使用 Falco YAML 规则在容器和 Kubernetes 中进行运行时威胁检测,监控系统调用以检测 shell 生成、文件篡改、网络异常和权限提升。通过 Falco gRPC API 管理 Falco 规则并解析 Falco 告警输出。适用于构建容器运行时安全或调查 k8s 集群入侵。

performing-cloud-incident-containment-procedures

9
from killvxk/cybersecurity-skills-zh

在 AWS、Azure 和 GCP 中执行云原生事件遏制,包括隔离受攻陷资源、撤销凭据、保全取证证据,以及应用安全组限制以防止横向移动。

performing-cloud-forensics-with-aws-cloudtrail

9
from killvxk/cybersecurity-skills-zh

使用 CloudTrail 日志对 AWS 环境执行取证调查,重建攻击者活动、识别受损凭据并分析 API 调用模式。

performing-cloud-forensics-investigation

9
from killvxk/cybersecurity-skills-zh

通过收集和分析来自 AWS、Azure 和 GCP 服务的日志、快照和元数据,在云环境中开展取证调查。

performing-cloud-asset-inventory-with-cartography

9
from killvxk/cybersecurity-skills-zh

使用 Cartography 执行全面的云资产清单和关系映射,在 AWS、GCP 和 Azure 中构建包含基础设施资产、IAM 权限和攻击路径的 Neo4j 安全图谱。

managing-cloud-identity-with-okta

9
from killvxk/cybersecurity-skills-zh

本技能涵盖将 Okta 部署为云环境集中身份提供商,配置与 AWS、Azure 和 GCP 的 SSO 集成,使用 Okta FastPass 部署抗钓鱼 MFA,管理用户预配置和取消配置的生命周期自动化,以及基于设备态势和风险信号实施自适应访问策略。

implementing-zero-trust-in-cloud

9
from killvxk/cybersecurity-skills-zh

本技能指导组织按照 NIST SP 800-207 和 Google BeyondCorp 原则在云环境中实施零信任(Zero Trust)架构,涵盖以身份为中心的访问控制、微分段(Micro-Segmentation)、持续验证、设备信任评估,以及部署身份感知代理(Identity-Aware Proxy)以消除 AWS、Azure 和 GCP 环境中的隐式网络信任。