Skip to content

Commit 80b860a

Browse files
committed
Add documentation for threat detection
1 parent 7628f4b commit 80b860a

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

docs/infra/threat-detection.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Threat Detection (AWS GuardDuty)
2+
3+
The infrastructure includes AWS GuardDuty for comprehensive threat detection and security monitoring across the AWS account. This document describes how GuardDuty is configured, its capabilities, and troubleshooting procedures.
4+
5+
## How threat detection works
6+
7+
GuardDuty analyzes tens of billions of events across multiple AWS data sources to detect malicious activity and unauthorized behavior:
8+
9+
- **AWS CloudTrail event logs** - API calls and user activities
10+
- **Amazon VPC Flow Logs** - Network traffic patterns
11+
- **DNS logs** - Domain name resolution requests
12+
- **S3 data events** - Object-level operations for malware detection
13+
14+
GuardDuty uses machine learning, anomaly detection, and integrated threat intelligence to identify threats including:
15+
16+
- Compromised instances communicating with malicious IPs
17+
- Cryptocurrency mining activities
18+
- Data exfiltration attempts
19+
- Malware in S3 objects
20+
- Reconnaissance attacks
21+
- Unusual API call patterns
22+
23+
## Malware detection for S3 storage
24+
25+
GuardDuty's malware detection feature continuously scans files uploaded to S3 buckets for malicious content. When malware is detected:
26+
27+
1. **File access is blocked** - Downloads of infected files are prevented
28+
2. **Findings are generated** - Security findings are created in the GuardDuty service with detailed information including:
29+
- **Finding ID** - Unique identifier for the security event
30+
- **Severity level** - Low, Medium, High, Critical
31+
- **Finding type** - Specific threat classification (e.g., `Malware:S3/MaliciousFile`)
32+
- **Resource details** - Affected S3 bucket, object key, and account information
33+
- **Timestamp** - When the malware was detected
34+
- **Evidence** - Technical details about the malicious content
35+
- **Remediation** - Recommended actions to address the threat
36+
3. **Tags are applied** - S3 objects are tagged with scan results for tracking:
37+
- **`GuardDutyMalwareScanStatus`** - Scan result status (`NO_THREATS_FOUND`, `THREATS_FOUND`)
38+
39+
### Checking S3 Object Tags for Malware Status
40+
41+
```bash
42+
#!/bin/bash
43+
44+
for plan_id in $(aws guardduty list-malware-protection-plans \
45+
--query "MalwareProtectionPlans[*].MalwareProtectionPlanId" \
46+
--output text); do
47+
48+
bucket=$(aws guardduty get-malware-protection-plan \
49+
--malware-protection-plan-id "$plan_id" \
50+
--query "ProtectedResource.S3Bucket.BucketName" \
51+
--output text 2>/dev/null)
52+
53+
if [ "$bucket" != "None" ] && [ -n "$bucket" ]; then
54+
echo "Scanning protected bucket: $bucket ..."
55+
56+
aws s3api list-objects-v2 --bucket "$bucket" \
57+
--query "Contents[*].Key" \
58+
--output text 2>/dev/null | tr '\t' '\n' | \
59+
while read -r key; do
60+
if [ -n "$key" ]; then
61+
tags=$(aws s3api get-object-tagging \
62+
--bucket "$bucket" \
63+
--key "$key" \
64+
--query "TagSet[?Key=='GuardDutyMalwareScanStatus' && Value=='THREATS_FOUND'].Value" \
65+
--output text 2>/dev/null)
66+
67+
if [ "$tags" = "THREATS_FOUND" ]; then
68+
echo "MALWARE DETECTED: s3://$bucket/$key"
69+
fi
70+
fi
71+
done
72+
fi
73+
done
74+
```
75+
76+
### Accessing GuardDuty Findings
77+
78+
**AWS Console:**
79+
- Navigate to GuardDuty Console → Findings
80+
- Filter by finding type, severity, or resource
81+
- View detailed finding information and evidence
82+
83+
## Deployment
84+
85+
GuardDuty is deployed as part of the account layer infrastructure:
86+
87+
```bash
88+
make infra-update-current-account
89+
```
90+
91+
### Malware Detection Errors
92+
93+
When GuardDuty detects malware in uploaded files, users may encounter the following errors:
94+
95+
#### File Download Blocked
96+
97+
**Error Message:**
98+
```
99+
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden
100+
```
101+
102+
**Cause:** GuardDuty's malware detection has identified the file as containing malware or suspicious content, and AWS S3 is blocking access with a 403 Forbidden error.

docs/system-architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This diagram shows the system architecture. [🔒 Make a copy of this Lucid temp
1414
* **Cognito** — Amazon Cognito handles authentication and user management.
1515
* **Database Role Manager** — AWS Lambda serverless function that provisions the database roles needed by the application.
1616
* **GitHub** — Source code repository. Also responsible for Continuous Integration (CI) and Continuous Delivery (CD) workflows. GitHub Actions builds and deploys releases to an Amazon ECR registry that stores Docker container images for the application service.
17+
* **GuardDuty Threat Detection** — AWS GuardDuty continuously monitors for malicious activity and unauthorized behavior across the AWS account, analyzing CloudTrail events, VPC Flow Logs, and DNS logs to detect security threats and anomalous activities. Additionally provides malware detection for files uploaded to S3 storage, preventing infected files from being downloaded.
1718
* **Incident Management Service** — Incident management service (e.g. PagerDuty or Splunk On-Call) for managing on-call schedules and paging engineers for urgent production issues.
1819
* **NAT Gateway** — Enables outbound internet access for resources in private subnets.
1920
* **Secrets Manager** — Securely stores and retrieves sensitive information such as database credentials.

0 commit comments

Comments
 (0)