Skip to content
intermediate Phase 7 · Cloud Security

Security Monitoring

Deploy GuardDuty for threat detection, Security Hub for compliance, and CloudTrail for API auditing across cloud accounts.

55m
0 problems
Topic Progress 0%

GuardDuty Threat Detection

Amazon GuardDuty is a managed threat detection service that continuously monitors for malicious activity and unauthorized behavior. It analyzes CloudTrail logs, VPC Flow Logs, DNS logs, and EKS audit logs.

GuardDuty requires no infrastructure to manage. Enable it in your account, and it immediately begins analyzing events. Findings are categorized by severity and type.

Finding Types:

  • Reconnaissance: IAM User permissions-reconnaissance, unusual API calls, port scanning
  • Behavior: Unusual data retrieval patterns, cryptocurrency mining, credential exfiltration
  • Unauthorized Access: Unauthorized access from a known malicious IP, compromised EC2 instance
  • Malware: Malicious file detected on an EC2 instance or S3 bucket

For example, GuardDuty detects an EC2 instance communicating with a known cryptocurrency mining command-and-control server. It generates a finding with severity score and affected resource details. Security Hub aggregates this finding with other services for unified visibility.

GuardDuty Integration with EventBridge enables automated responses. When a high-severity finding is detected, trigger a Lambda function to isolate the affected EC2 instance by modifying its security group, or rotate credentials for a compromised IAM user.

Cost Optimization: GuardDuty charges per event analyzed. Use CloudWatch Logs to monitor GuardDuty cost, and consider excluding accounts or regions with no sensitive workloads. For organizations, enable GuardDuty at the organization level to manage costs centrally.

Security Hub Standards and Controls

AWS Security Hub provides a centralized view of security findings across AWS accounts and services. It aggregates findings from GuardDuty, Inspector, Macie, IAM Access Analyzer, Firewall Manager, and third-party tools.

Security Standards define compliance frameworks with specific controls. Security Hub supports:

  • AWS Foundational Security Best Practices: 50+ controls covering common security issues
  • CIS AWS Foundations Benchmark: Industry-standard security configuration
  • PCI DSS v3.2.1: Payment card industry compliance
  • NIST SP 800-53: Federal information security standards

Each standard contains controls with pass/fail status. For example, the control S3.1 checks whether S3 buckets have public access disabled. Failed controls generate findings that appear in Security Hub.

Compliance Score provides an overall security posture percentage. Track this score over time to measure improvement. A score below 50% indicates critical security gaps.

Custom Insights group findings by attributes you define. Create an insight for all critical findings in the production account, or all findings related to a specific resource type.

Automated Response uses EventBridge rules triggered by Security Hub findings. For example, when a critical finding is detected, automatically create a ticket in your ticketing system, notify the security team via SNS, and remediate the issue using Systems Manager Automation runbooks.

Security Hub is the recommended central point for security monitoring in AWS.

CloudTrail Configuration and Log Management

AWS CloudTrail logs API calls made in your AWS account. It is the foundation of security monitoring and compliance auditing.

Trail Configuration determines what CloudTrail logs. Create a trail to log all management events (IAM, EC2, S3 API calls) across all regions. Store logs in S3 for long-term retention and analysis.

Management Events capture control-plane operations: creating instances, modifying security groups, changing IAM policies. These are the most important events for security auditing.

Data Events capture data-plane operations: S3 object-level operations, Lambda function invocations. Enable data events only for specific resources, as they generate high volume. For example, enable data events only for a sensitive S3 bucket, not all buckets.

Log File Validation uses digest files to verify CloudTrail log integrity. Enable log file validation to detect tampering. Digest files contain hashes of the log files; any modification to the logs invalidates the hash.

Organization Trails aggregate logs from all accounts in an AWS Organization to a central S3 bucket. This provides a single location for all account activity, simplifying compliance auditing and forensic analysis.

CloudWatch Logs Integration streams CloudTrail logs to CloudWatch for real-time monitoring. Create metric filters for specific events (e.g., root login attempts) and CloudWatch alarms that notify when thresholds are exceeded.

For example, create a filter for errorCode: AccessDenied events and alarm when the count exceeds 100 in 5 minutes, indicating potential unauthorized access attempts.

Security Service Integration and Response

The real power of AWS security monitoring comes from integrating multiple services into a cohesive defense-in-depth strategy.

Event-Driven Architecture connects security services through EventBridge:

  1. GuardDuty detects a threat -> EventBridge rule -> Lambda function isolates EC2 instance
  2. Security Hub finds a failed control -> EventBridge rule -> SNS notification to security team
  3. CloudTrail detects root login -> EventBridge rule -> Systems Manager automation to investigate

AWS Config tracks resource configuration changes and evaluates them against rules. When an S3 bucket becomes public, Config detects the change and triggers a Config rule that automatically blocks public access.

Macie discovers and protects sensitive data in S3 (PII, financial data). Integrate Macie findings with Security Hub to monitor sensitive data exposure alongside other security threats.

Incident Response Workflow:

  1. Detect: GuardDuty identifies suspicious activity
  2. Investigate: Security Hub aggregates findings; CloudTrail provides API history
  3. Respond: EventBridge triggers automated remediation
  4. Recover: Restore from snapshots or rotate compromised credentials
  5. Improve: Update Config rules and security policies to prevent recurrence

For a compromised EC2 instance: GuardDuty detects crypto-mining, EventBridge triggers a Lambda that modifies the instance security group to isolate it, SNS notifies the security team, and CloudTrail logs the remediation actions for audit.

Quiz

1. What data sources does GuardDuty analyze?

Question 1 options

2. What is the purpose of Security Hub compliance score?

Question 2 options

3. What is the difference between management and data events in CloudTrail?

Question 3 options

4. How does log file validation help with CloudTrail?

Question 4 options

5. What service connects security events to automated responses?

Question 5 options

Flashcards

Question

GuardDuty

Answer

Managed threat detection service analyzing CloudTrail, VPC Flow Logs, DNS logs, and EKS audit logs. Generates findings by threat type and severity.

Question

Security Hub

Answer

Centralized security view aggregating findings from multiple services. Provides compliance scoring against standards like CIS and PCI DSS.

Question

CloudTrail

Answer

Logs API calls across your AWS account. Management events capture control-plane operations; data events capture data-plane operations.

Question

Organization Trail

Answer

A CloudTrail configuration that aggregates logs from all accounts in an AWS Organization to a central S3 bucket for unified auditing.

Question

EventBridge Security Integration

Answer

Routes security findings from GuardDuty, Security Hub, and CloudTrail to automated responses like Lambda functions and SNS notifications.

Revision Notes

Key Takeaways

  • 1. GuardDuty analyzes CloudTrail, VPC Flow Logs, DNS logs for threat detection
  • 2. Security Hub aggregates findings and provides compliance scoring against standards
  • 3. CloudTrail logs management events (control-plane) and data events (data-plane)
  • 4. Log file validation uses digest hashes to detect log tampering
  • 5. EventBridge connects security events to automated remediation
  • 6. Organization trails centralize logs from all accounts for auditing

Interview Tips

  • Describe the incident response workflow: detect, investigate, respond, recover, improve
  • Explain how GuardDuty detects threats without infrastructure
  • Discuss Security Hub compliance standards and how to use them
  • Explain CloudTrail log file validation and why it matters
  • Design an automated response for a compromised EC2 instance

Cheat Sheet

GuardDuty = threat detection (CloudTrail + VPC Flow Logs + DNS). Security Hub = centralized findings + compliance score. CloudTrail = API audit logs (management + data events). Log validation = digest hashes detect tampering. EventBridge = event routing for automated response. Organization trails = centralize logs from all accounts.