GeekyBlessing/aws-guardduty-alerting-pipeline

GitHub: GeekyBlessing/aws-guardduty-alerting-pipeline

基于 AWS GuardDuty 的无服务器安全自动化管道,结合 MITRE ATT&CK 映射、CloudTrail 关联与 Lambda 实现威胁检测和自动修复闭环。

Stars: 1 | Forks: 1

# 🛡️ AWS GuardDuty 自动化修复 Pipeline ![AWS](https://img.shields.io/badge/AWS-Cloud-orange) ![Terraform](https://img.shields.io/badge/IaC-Terraform-purple) ![Lambda](https://img.shields.io/badge/Serverless-Lambda-yellow) ![MITRE](https://img.shields.io/badge/MITRE-ATT%26CK-red) 一个生产级、无服务器的云安全自动化 Pipeline,利用 MITRE ATT&CK 情报实时检测、调查并修复 AWS 安全威胁。 ## 🏗️ 架构 ``` GuardDuty Finding ↓ EventBridge (severity >= 7 filter) ↓ Lambda (guardduty-alert-processor) ↓ ┌─────────────────────────────────┐ │ THREAT INTELLIGENCE ENGINE │ │ • MITRE ATT&CK Mapping │ │ • Dynamic Risk Scoring (0-100) │ │ • CloudTrail Correlation │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ AUTO-REMEDIATION ENGINE │ │ • IAM: Full lockdown │ │ • EC2: Forensic isolation │ │ • S3: Public access block │ └─────────────────────────────────┘ ↓ ┌─────────────────────────────────┐ │ INCIDENT MANAGEMENT │ │ • DynamoDB audit trail │ │ • CloudWatch custom metrics │ │ • SNS email alerting │ └─────────────────────────────────┘ ``` ## ✨ 功能特性 ### 🔍 威胁情报 - **MITRE ATT&CK 映射** - 每个发现都标记了技术 ID 和战术 - **动态风险评分** - 根据发现类型和严重程度计算 0-100 的分数 - **CloudTrail 关联分析** - 查询受损实体最近的 10 次 API 调用 ### ⚡ 自动化修复 | 发现类型 | 严重程度 | 操作 | |-------------|----------|--------| | IAMUser/UnauthorizedAccess | 7+ | 禁用访问密钥,分离策略 | | IAMUser/UnauthorizedAccess | 9+ | 完全锁定(密钥 + 策略 + 组 + 控制台) | | EC2/CryptoCurrency | 7+ | 隔离至隔离安全组 + 取证标签 | | EC2/Backdoor | 9+ | 隔离 + 停止实例以进行取证分析 | | S3/BucketPublicAccess | 7+ | 阻止公开访问 + 应用拒绝策略 | ### 📊 可观测性 - **DynamoDB** 事件日志,带有 90 天 TTL - **CloudWatch** 自定义指标命名空间 (`GuardDuty/AutoRemediation`) - **SNS** 包含 MITRE 背景信息的专业 IR 报告 ## 🛠️ 技术栈 - **AWS GuardDuty** - 威胁检测 - **AWS EventBridge** - 无服务器事件路由 - **AWS Lambda** (Node.js 20.x) - 自动修复引擎 - **AWS DynamoDB** - 事件审计追踪 - **AWS CloudTrail** - 取证活动关联 - **AWS CloudWatch** - 自定义安全指标 - **AWS SNS** - 告警推送 - **Terraform** - 基础设施即代码 ## 📧 告警输出示例 ``` 🟠 GUARDDUTY AUTO-REMEDIATION REPORT 🟠 ══════════════════════════════════════ THREAT INTELLIGENCE ─────────────────── MITRE ATT&CK: T1078 - Valid Accounts Tactic: Defense Evasion Risk Score: 70/100 FINDING DETAILS ─────────────── Type: UnauthorizedAccess:IAMUser/MaliciousIPCaller Severity: 7/10 Account: 358487322954 Region: eu-north-1 AUTOMATED RESPONSE ────────────────── 🔑 Disabled access key: AKIA... 📋 Detached policy: AdministratorAccess 🚫 Console access revoked ``` ## 🚨 真实事件案例研究 此 Pipeline 是基于在生产 AWS 环境中检测到的**真实的严重程度为 8 的 GuardDuty 发现**(`UnauthorizedAccess:IAMUser`)构建和测试的。 **时间线:** 1. GuardDuty 检测到 `UnauthorizedAccess:IAMUser` - 严重程度 8 2. EventBridge 在 < 1 秒内将发现路由至 Lambda 3. Lambda 计算风险评分:80/100,MITRE:T1078 4. CloudTrail 关联分析检索了受损用户最近的 10 次 API 调用 5. 自动禁用了所有访问密钥 6. 将带有完整取证背景的事件记录到 DynamoDB 7. 通过电子邮件发送包含 MITRE 丰富信息的 IR 报告 ## 🏗️ 使用 Terraform 部署 ``` # Clone 仓库 git clone https://github.com/GeekyBlessing/aws-guardduty-alerting-pipeline.git cd aws-guardduty-alerting-pipeline # 初始化 Terraform terraform init # 预览更改 terraform plan # 部署所有基础设施 terraform apply # 导入现有资源(如果已经手动部署) terraform import aws_guardduty_detector.main terraform import aws_sns_topic.security_alerts terraform import aws_dynamodb_table.incidents guardduty-incidents terraform import aws_lambda_function.guardduty_processor guardduty-alert-processor ``` ## 📁 项目结构 ``` aws-guardduty-alerting-pipeline/ ├── lambda/ │ └── index.mjs # Auto-remediation engine (384 lines) ├── main.tf # Terraform infrastructure definition ├── variables.tf # Configuration variables ├── outputs.tf # Output values ├── .gitignore # Excludes sensitive files └── README.md # This file ``` ## 🔐 安全考量 - Terraform state 排除在版本控制之外 - AWS 凭证绝不存储在代码中 - 为 Lambda 执行配置最小权限的 IAM 角色 - 基于严重程度的响应层级(仅通知 vs 自动修复) - DynamoDB TTL 确保数据在 90 天后自动过期 - 所有敏感配置均通过 Lambda 环境变量传递 ## 👨‍💻 作者 **GeekyBlessing** - 云安全工程师 [![GitHub](https://img.shields.io/badge/GitHub-GeekyBlessing-black)](https://github.com/GeekyBlessing)
标签:AMSI绕过, AWS, DPI, ECS, Serverless, Terraform, 云计算, 威胁检测, 安全运营, 扫描框架, 自动化响应, 自定义脚本, 规则引擎