Guides deployment and operation of Amazon GuardDuty for continuous AWS threat detection on S3, EKS, EC2 runtime monitoring, and Lambda. Covers finding severity interpretation and EventBridge/Lambda response automation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cybersecurity-skills-zh:detecting-cloud-threats-with-guarddutyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- 为新建或现有 AWS 账户建立持续威胁检测时
不适用于:Azure 或 GCP 的威胁检测(请参阅 securing-azure-with-microsoft-defender 或 auditing-gcp-security-posture)、静态代码分析,或合规态势监控(请参阅 implementing-aws-security-hub)。
使用委派管理员账户在组织层面激活 GuardDuty,并启用所有保护计划,包括 S3 Protection、EKS Audit Log Monitoring、Runtime Monitoring、Malware Protection、RDS Login Activity 和 Lambda Network Activity Monitoring。
# 启用 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
自动注册所有组织成员账户,并将发现导出至中央 S3 存储桶,用于数据留存和 SIEM 接入。
# 为所有组织成员自动启用 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"
}'
GuardDuty 将发现分为四个严重级别:严重(Critical)、高(High)、中(Medium)和低(Low)。每种发现类型遵循 ThreatPurpose:ResourceType/ThreatName 格式。扩展威胁检测(Extended Threat Detection)生成跨时间关联多个事件的攻击序列发现。
主要发现类别:
创建 EventBridge 规则,将 GuardDuty 发现路由至 Lambda 函数执行自动遏制操作,例如隔离被入侵的 EC2 实例、撤销 IAM 凭据或封锁恶意 IP 地址。
# 针对高危/严重 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 示例:
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}
审查关联 EC2、ECS 和 EKS 多个信号的严重级别攻击序列发现。这些发现代表多阶段攻击,例如通过被入侵凭据初始访问,继而持久化、横向移动和挖矿。
# 列出严重攻击序列发现
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>
将 GuardDuty 发现转发至 AWS Security Hub 进行集中聚合,并通过 S3 导出或 Amazon Security Lake 传送至外部 SIEM 平台,用于长期留存和跨来源关联分析。
# 验证 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 信誉列表和域名威胁订阅源 |
场景背景:GuardDuty 生成针对 ECS Fargate 任务的 CryptoCurrency:Runtime/BitcoinTool.B 高危发现。Runtime Monitoring 检测到容器内执行了挖矿程序。
方法:
常见陷阱:在未保留容器镜像的情况下停止任务会丢失取证证据。未能追溯到 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
npx claudepluginhub killvxk/cybersecurity-skills-zhDeploys and operationalizes Amazon GuardDuty for continuous threat detection across AWS accounts. Covers enabling protection plans, interpreting findings, and building automated response workflows.
Deploys and operationalizes Amazon GuardDuty for continuous threat detection across AWS accounts. Covers enabling protection plans, interpreting findings, and building automated response workflows.
Deploys and operationalizes Amazon GuardDuty for AWS threat detection across accounts and workloads, enabling S3/EKS/EC2/Lambda protections, interpreting findings, and automating responses with EventBridge/Lambda.