Overview
This project demonstrates a cloud-native threat detection pipeline on AWS — simulating the detection engineering layer that a small-to-medium enterprise security team would need as a minimum viable security operations baseline.
Goal: Build an end-to-end threat detection pipeline ingesting AWS native telemetry, with enriched alerts and documented detection logic.
Architecture
CloudTrail → S3 → Lambda (enrichment) → OpenSearch
GuardDuty → EventBridge → SNS → Lambda → OpenSearch
VPC Flow Logs → S3 → Athena → Dashboard
Key design decisions:
- No EC2 required — 100% serverless for the detection layer
- GuardDuty as the primary anomaly detector — supplements custom rules
- Lambda enrichment functions — add GeoIP, account context, asset classification
- OpenSearch — Kibana dashboards for triage
Detection Rules Built
| Rule | Tactic | Severity |
|---|---|---|
| Root account login | Initial Access | Critical |
| IAM user created + MFA disabled | Persistence | High |
| S3 bucket policy changed to public | Exfiltration | High |
| Security group egress rule added | Defense Evasion | Medium |
| Unusual API calls from new geo | Discovery | Medium |
Key Implementation Notes
CloudTrail → Lambda Pipeline
import boto3
import json
import os
def enrich_event(event):
"""Add asset classification and account context to CloudTrail events."""
account_id = event.get('userIdentity', {}).get('accountId')
region = event.get('awsRegion')
event_name = event.get('eventName')
enriched = {
**event,
'rh_account_tier': classify_account(account_id),
'rh_region_risk': get_region_risk_score(region),
'rh_is_sensitive_api': event_name in SENSITIVE_APIS,
}
return enriched
SENSITIVE_APIS = {
'CreateUser', 'AttachUserPolicy', 'PutBucketPolicy',
'ModifyInstanceAttribute', 'GetSecretValue', 'DeleteTrail'
}
Outcome & Metrics
- MTTD before: ~4 hours (manual triage of GuardDuty console)
- MTTD after: < 8 minutes (automated enrichment → SNS alert → Slack)
- False positive rate: 12% initial → 3% after 2 weeks of tuning
- Coverage: 18 detection rules across 6 MITRE ATT&CK tactics
Repo & Code
The infrastructure-as-code (Terraform) and Lambda functions for this lab are available in the cloud-security-labs GitHub repo.