Searching and Correlating Logs for Security Events
Searching and correlating logs is a core Incident Response skill in SCS-C03. It covers how you collect evidence, identify indicators of compromise, and reconstruct attacker activity across AWS services. Key log sources include AWS CloudTrail for API activity (who did what, when, and from where), VPC Flow Logs for network traffic metadata, and Route 53 Resolver query logs for DNS lookups. Other sources are S3 server access logs, Elastic Load Balancing and CloudFront access logs, AWS WAF logs, and application or OS logs shipped through the CloudWatch agent. Searching tools: Amazon CloudWatch Logs Insights provides a purpose-built query language to filter, parse, and aggregate log events in near real time. Amazon Athena runs SQL against logs stored in S3. It suits CloudTrail and Flow Logs at scale, especially when the data is partitioned. CloudTrail Lake offers managed, immutable event data stores that you query with SQL, with multi-account and multi-Region aggregation. Amazon OpenSearch Service supports full-text search and dashboards for SIEM-like analysis. Correlation tools: Amazon Detective builds a behavior graph from CloudTrail, VPC Flow Logs, GuardDuty findings, and EKS audit logs. Investigators can pivot between entities such as IAM roles, IP addresses, and EC2 instances to visualize scope and timeline. AWS Security Hub aggregates and normalizes findings using the AWS Security Finding Format (ASFF). Amazon Security Lake centralizes logs in Open Cybersecurity Schema Framework (OCSF) format, which enables consistent cross-source queries and third-party SIEM integration. Correlation techniques: Join events on common fields such as access key ID, principal ARN, source IP, instance ID, and timestamps. For example, a GuardDuty finding on unusual API calls can be traced in CloudTrail to a specific access key. That key's activity can then be matched to Flow Logs showing large outbound transfers that indicate data exfiltration. Exam tips: Centralize logs in a dedicated security account using AWS Organizations. Enable CloudTrail log file integrity validation, and protect logs with S3 Object Lock and KMS encryption. Choose Detective for root-cause investigation and Athena for ad hoc SQL queries. Keep timestamps in UTC so timelines remain accurate.
Searching and Correlating Logs for Security Events (AWS Security Specialty: Threat Detection and Incident Response)
During a security incident, a single log entry rarely tells the whole story. An attacker may use a stolen access key (seen in AWS CloudTrail), connect from a suspicious IP (seen in VPC Flow Logs), resolve a command-and-control domain (seen in Route 53 Resolver query logs), and exfiltrate data (seen in S3 server access logs or CloudTrail data events). Log correlation is the practice of searching across these sources and linking related events by common attributes so you can rebuild the attack timeline, find the scope of compromise, and choose the right containment actions. On the AWS Certified Security - Specialty exam, this topic falls within the Threat Detection and Incident Response domain and appears often in scenario questions.
Why It Is Important
- Scope determination: Correlation shows which identities, resources, Regions, and accounts were touched, not just the single resource that raised an alert.
- Root cause analysis: It reveals the initial access vector, such as a leaked IAM access key, an exposed EC2 instance, or a misconfigured S3 bucket policy.
- Accurate containment: If you know every session and credential the attacker used, you can revoke all of them rather than one.
- Evidence and compliance: Correlated, time-ordered evidence supports forensic reports, legal needs, and regulatory obligations.
- Reduced false positives: A single GuardDuty finding may be benign; correlating it with CloudTrail and flow data confirms or rules out malicious activity.
What It Is: The Key Log Sources
- AWS CloudTrail: Records API activity. Management events (control plane, enabled by default for 90 days in Event history) and data events (for example S3 GetObject, Lambda Invoke, DynamoDB item operations, which must be enabled explicitly and incur cost). CloudTrail Insights detects unusual API call rates or error rates.
- CloudTrail Lake: A managed event data store that lets you run SQL queries on CloudTrail events (and other integrated sources) across accounts and Regions, with retention up to 10 years on supported pricing options.
- VPC Flow Logs: Network metadata (source/destination IP, ports, protocol, bytes, ACCEPT/REJECT). No packet payloads. For payloads you need VPC Traffic Mirroring.
- Route 53 Resolver query logs: DNS queries made from within VPCs, useful for detecting malware beaconing and DNS exfiltration.
- Amazon S3 server access logs: Detailed request records for buckets (best effort delivery); CloudTrail data events are the more reliable choice for security auditing.
- Elastic Load Balancing access logs, AWS WAF logs, CloudFront logs: Application-layer request data including client IPs, URIs, and WAF rule matches.
- Amazon CloudWatch Logs: Central store for OS, application, Lambda, and agent logs; searchable with CloudWatch Logs Insights.
- AWS Config: Configuration history and change timeline for resources, answering what a resource looked like at a given time.
- Amazon EKS audit logs, RDS logs, and AWS Systems Manager Session Manager logs: Workload-specific activity.
The AWS Services That Help You Search and Correlate
- Amazon Detective: Purpose-built for investigation. It ingests CloudTrail, VPC Flow Logs, GuardDuty findings, and EKS audit logs, then builds a behavior graph linking IAM principals, IP addresses, EC2 instances, and more. It offers visualizations of activity over time and up to a year of aggregated data. Best answer when a question asks to investigate the root cause or scope of a GuardDuty finding with the least effort.
- Amazon GuardDuty: Threat detection (not investigation) using CloudTrail, VPC Flow Logs, DNS logs, and optional protection plans (S3, EKS, RDS, Lambda, Malware Protection, Runtime Monitoring). Findings feed Detective and Security Hub.
- AWS Security Hub: Aggregates and normalizes findings in the AWS Security Finding Format (ASFF) from GuardDuty, Inspector, Macie, IAM Access Analyzer, Config, and third parties. Supports cross-Region aggregation and insights for grouping related findings.
- Amazon Security Lake: Centralizes security logs from AWS sources and third parties into an S3-based data lake in your account, normalized to the Open Cybersecurity Schema Framework (OCSF). Queried by Athena or subscriber tools such as SIEMs.
- Amazon Athena: Serverless SQL over logs stored in S3 (CloudTrail, Flow Logs, ALB, WAF logs). Use partitioning (for example partition projection by date, account, Region) to reduce cost and time.
- CloudWatch Logs Insights: Interactive query language for logs in CloudWatch Logs, can query multiple log groups at once.
- Amazon OpenSearch Service: Full text search, dashboards, and SIEM-like correlation at scale, often fed via Kinesis Data Firehose or subscription filters.
- Amazon EventBridge: Real-time routing of findings and API events to automated responses (Lambda, Step Functions, SNS).
How It Works: The Correlation Process
1. Centralize the logs. Use an organization trail in AWS Organizations to send CloudTrail from all accounts and Regions to a dedicated Log Archive account S3 bucket. Protect it with S3 Object Lock, bucket policies, SSE-KMS, and CloudTrail log file integrity validation (SHA-256 digest files) to prove logs were not altered. Designate a delegated administrator in a Security Tooling account for GuardDuty, Security Hub, Detective, and Security Lake.
2. Normalize timestamps and formats. CloudTrail uses UTC. Flow logs use Unix epoch start/end times. Security Lake with OCSF and Security Hub with ASFF remove format differences.
3. Identify pivot fields (correlation keys).
- userIdentity.accessKeyId: track every API call made by a compromised key.
- userIdentity.arn and principalId: identify the role session; the session name portion often shows the human or service behind it.
- userIdentity.sessionContext.sourceIdentity: persists across role chaining, letting you trace the original user who assumed roles.
- sourceIPAddress and userAgent: link API calls to network activity in Flow Logs, WAF, and ALB logs.
- eventTime: build the timeline.
- requestID and eventID: uniquely reference specific calls.
- Resource IDs (instance ID, ENI ID, bucket name): connect CloudTrail to Flow Logs (which are tied to ENIs) and Config history.
- recipientAccountId: identifies cross-account activity.
4. Trace AssumeRole chains. When an attacker uses temporary credentials, search CloudTrail for the AssumeRole, AssumeRoleWithWebIdentity, AssumeRoleWithSAML, or GetSessionToken event that issued them. The response contains the temporary accessKeyId; then search all events that used that key. Note that STS events are recorded in the Region of the endpoint called, and global service events (for example IAM) are recorded in us-east-1.
5. Query. Example Athena logic: select eventTime, eventName, sourceIPAddress, awsRegion from the CloudTrail table where userIdentity.accessKeyId equals the compromised key, ordered by eventTime. Then take the source IPs found and query the Flow Logs table for those addresses to see which instances communicated with them.
6. Visualize and confirm. Use Detective to view the entity profile of the IP or role, see first and last observed times, and find related findings.
7. Feed results into response. Revoke sessions (for roles, use the Revoke active sessions option, which adds an inline deny policy based on aws:TokenIssueTime), deactivate access keys, isolate instances with a restrictive security group, snapshot EBS volumes for forensics, and record the timeline.
Common Pitfalls Tested on the Exam
- CloudTrail Event history covers only 90 days of management events and does not include data events; longer or data event analysis needs a trail to S3, CloudTrail Lake, or Security Lake.
- Flow Logs do not capture payload contents, DNS traffic to the Amazon DNS server, instance metadata (169.254.169.254) traffic, or Amazon Time Sync traffic.
- S3 data access (GetObject) is invisible in CloudTrail unless data events are enabled.
- CloudTrail delivery to S3 typically happens within about 5 minutes on average; it is not real-time. For near real-time detection, use EventBridge or send CloudTrail to CloudWatch Logs with metric filters and alarms.
- Detective requires GuardDuty to be enabled (for at least 48 hours historically) before it can build its behavior graph.
- Logs stored in an account the attacker controls can be deleted; a separate Log Archive account with restricted access is the secure design.
Exam Tips: Answering Questions on Searching and Correlating Logs for Security Events
1. Match the verb to the service. Detect points to GuardDuty, aggregate/prioritize findings points to Security Hub, investigate/visualize/root cause points to Detective, query logs with SQL in S3 points to Athena, centralize and normalize logs from many sources including third parties points to Security Lake, query CloudTrail with SQL and long retention as a managed service points to CloudTrail Lake, query application logs interactively points to CloudWatch Logs Insights.
2. Look for the phrase 'least operational overhead'. Managed options (Detective, CloudTrail Lake, Security Lake, Security Hub) usually beat custom Lambda parsers, self-managed ELK on EC2, or manual downloads of log files.
3. Know which log holds which evidence. Who made an API call: CloudTrail. What IPs talked to an instance: VPC Flow Logs. Which domains were resolved: Route 53 Resolver query logs. Which objects were read: CloudTrail S3 data events. Who changed a security group and what it looked like before: CloudTrail plus AWS Config.
4. Multi-account means organization-wide. When the scenario spans many accounts, prefer an organization trail, delegated administrator for GuardDuty/Security Hub/Detective, and Security Hub cross-Region aggregation.
5. Trust in log integrity. If the question asks how to prove logs were not tampered with, choose CloudTrail log file integrity validation; for preventing deletion, choose S3 Object Lock and MFA Delete in a separate account.
6. Temporary credentials require tracing the STS call. If the scenario says a role was abused, the correct path usually involves finding the AssumeRole event, the session name or sourceIdentity, and all calls using the issued key.
7. Watch the time windows. Requirements older than 90 days rule out Event history alone. Requirements for near real-time rule out Athena batch queries over S3 as the sole answer.
8. Performance and cost in Athena. Choose partitioning, partition projection, and columnar formats (Parquet) when the question complains about slow or costly queries over large log volumes.
9. Eliminate distractors. Amazon Inspector finds vulnerabilities, not attacker activity; Amazon Macie finds sensitive data in S3, not network events; AWS Trusted Advisor gives best-practice checks, not incident timelines. These are frequent wrong options in correlation questions.
10. Preserve before you remediate. In incident response sequencing questions, the best answers collect and protect evidence (logs, EBS snapshots, memory captures) before terminating resources, since termination can destroy evidence needed for correlation.
Quick Summary
Centralize logs securely, normalize them, pivot on shared identifiers such as access key ID, role session, source IP, resource ID, and time, and use the right AWS tool for each step: GuardDuty to detect, Security Hub to aggregate, Detective to investigate, Athena, CloudTrail Lake, CloudWatch Logs Insights, or Security Lake to query, and EventBridge to automate the response.