Capturing Logs as Forensic Artifacts
In AWS incident response, logs are critical forensic artifacts. Investigators use them to reconstruct attacker activity, build timelines, and support legal or compliance requirements. For the SCS-C03 exam, you must know which logs to capture, how to preserve their integrity, and how to store them securely. Key log sources include: - AWS CloudTrail: API activity and account actions. - VPC Flow Logs: network traffic metadata. - Amazon Route 53 Resolver query logs: DNS lookups. - Elastic Load Balancing, Amazon CloudFront, and Amazon S3 server access logs. - AWS Config: resource configuration history. - Operating system and application logs collected through the Amazon CloudWatch agent. Amazon GuardDuty findings and AWS Security Hub data add further context. Integrity is essential. Enable CloudTrail log file integrity validation. It creates SHA-256 hashed digest files that prove logs were not altered. Store logs in a dedicated, centralized log archive account managed through AWS Organizations, and restrict access with strict bucket policies and service control policies. Enable versioning, then apply S3 Object Lock in compliance mode for write-once-read-many (WORM) protection. Encrypt logs with AWS KMS customer managed keys and tightly control the key policies. During an incident, preserve ephemeral data quickly. Logs stored on EC2 instances can be lost if an instance is terminated, so collect them before containment actions such as isolation or termination. Capture EBS snapshots and memory images alongside the logs. Maintain chain of custody by recording artifact hashes and documenting who accessed each artifact, when, and why. For analysis, you can use: - Amazon Athena to query logs stored in S3. - CloudWatch Logs Insights. - CloudTrail Lake. - Amazon Detective to visualize relationships between resources and activity. Amazon Security Lake normalizes logs into the Open Cybersecurity Schema Framework (OCSF) for centralized investigation. Exam tips: - Favor automated, centralized, immutable, and encrypted log collection established before incidents occur. - Set retention periods that meet compliance requirements. - Separate forensic and log archive accounts from production workloads to prevent tampering. - Prefer prevention controls such as Object Lock and integrity validation over detective controls alone when evidence protection is required.
Capturing Logs as Forensic Artifacts in AWS: Preservation, Integrity and Exam Strategy
In the AWS Certified Security - Specialty exam, the domain Threat Detection and Incident Response expects you to know how to collect, preserve and protect evidence after a security event. Logs are among the most valuable forensic artifacts because they record who did what, when, from where and against which resource. This guide explains what log-based forensic artifacts are, why they matter, how to capture them correctly on AWS, and how to answer exam questions on the topic.
1. Why Capturing Logs as Forensic Artifacts Is Important
Reconstructing the timeline: Logs let investigators rebuild the sequence of attacker actions, such as initial access, privilege escalation, persistence, lateral movement and data exfiltration.
Attribution and scope: API logs identify the IAM principal, access key, source IP and user agent. This shows which credentials were compromised and which accounts, Regions and resources were affected.
Legal and regulatory requirements: Frameworks such as PCI DSS, HIPAA and SOC 2, as well as legal proceedings, require evidence that is complete, tamper-evident and handled with a documented chain of custody.
Attackers target logs: A common attacker technique is to call StopLogging, DeleteTrail, DeleteFlowLogs or to delete S3 log objects to hide their tracks. Evidence that is not protected can be lost or questioned.
Ephemeral infrastructure: Auto Scaling, containers and Lambda functions can disappear in minutes. If logs are not shipped off the resource, the evidence disappears with it.
Root cause and lessons learned: Preserved logs support post-incident reviews and help you improve controls so the same event does not happen again.
2. What Log-Based Forensic Artifacts Are
A forensic artifact is any data that provides evidence about an event. On AWS, the main log sources are:
AWS CloudTrail: Records management events (control plane API calls), and optionally data events (for example S3 GetObject and PutObject, Lambda Invoke, DynamoDB item activity) and Insights events (unusual API call rates). This is the primary source for who did what.
CloudTrail Lake: A managed, queryable event data store with SQL querying and long retention options, useful for investigations across accounts.
VPC Flow Logs: Capture IP traffic metadata (source, destination, ports, protocol, bytes, accept or reject) for VPCs, subnets or ENIs. Useful for detecting exfiltration, command and control traffic and port scanning. They do not capture packet payloads.
VPC Traffic Mirroring: Copies actual packets from ENIs to a monitoring target for deep packet inspection when payload content is needed.
Route 53 Resolver query logs: Record DNS queries made from within VPCs, useful for spotting domain generation algorithms, DNS tunneling and malicious domains.
Amazon S3 server access logs: Detailed records of requests to a bucket. CloudTrail data events are the alternative with richer identity context.
Elastic Load Balancing access logs, CloudFront logs and AWS WAF logs: Record HTTP requests, client IPs and matched WAF rules, valuable for web attacks such as SQL injection.
Amazon CloudWatch Logs: Central store for application logs, OS logs gathered by the CloudWatch agent, Lambda function logs, API Gateway logs and more.
Amazon EKS control plane logs: API server, audit, authenticator, controller manager and scheduler logs. The audit log is essential for Kubernetes investigations.
Amazon RDS and Aurora logs: Database audit, error and slow query logs that can be published to CloudWatch Logs.
AWS Config: Configuration history and snapshots showing how a resource looked before, during and after the incident.
Amazon GuardDuty findings and Amazon Detective: GuardDuty analyzes CloudTrail, VPC Flow Logs, DNS logs and more to produce findings. Detective builds behavior graphs from these sources to support investigation. Findings themselves should be exported (for example through EventBridge to S3) because GuardDuty retains findings for only 90 days.
Host-level artifacts: OS logs (for example /var/log, Windows Event Logs), application logs, memory images and EBS snapshots from EC2 instances.
3. How Capturing Logs as Forensic Artifacts Works
Step 1 - Enable logging before an incident happens
You cannot capture what was never recorded. Best practice is to have logging in place proactively:
- Create an organization trail in AWS Organizations covering all accounts and all Regions, including global service events.
- Enable CloudTrail data events for sensitive S3 buckets and Lambda functions.
- Enable VPC Flow Logs, Route 53 Resolver query logs, ELB access logs, WAF logs and EKS audit logs.
- Install the CloudWatch agent on EC2 instances to ship OS and application logs off the host.
- Enable GuardDuty, Security Hub and Detective with a delegated administrator account.
Step 2 - Centralize logs in a dedicated log archive account
Send logs to an S3 bucket in a separate, tightly controlled Log Archive account (as used in AWS Control Tower and the AWS Security Reference Architecture). Even if a workload account is fully compromised, the attacker cannot alter logs held in a different account. Use bucket policies that allow writes from the logging services but deny deletion and modification from workload accounts.
Step 3 - Ensure integrity (tamper evidence)
- CloudTrail log file integrity validation: CloudTrail creates hourly digest files containing SHA-256 hashes of each log file, signed with SHA-256 with RSA. You can run aws cloudtrail validate-logs to prove whether log files were modified, deleted or remained unchanged. This is the key feature for proving evidence integrity.
- Hashing collected artifacts: When you copy logs, memory dumps or disk images, compute and record hashes so you can show the evidence has not changed.
Step 4 - Ensure immutability and retention
- S3 Object Lock in compliance mode prevents any user, including the root user, from deleting or overwriting objects until the retention period ends. Governance mode allows users with special permissions to bypass the lock. Legal hold preserves objects indefinitely until the hold is removed, which is ideal for an active investigation.
- S3 Versioning and MFA Delete protect against accidental or malicious deletion.
- S3 Lifecycle policies move older logs to S3 Glacier storage classes for low-cost long-term retention.
- S3 Replication (cross-Region or cross-account) creates additional protected copies.
- CloudWatch Logs retention settings should be set deliberately, since the default is to keep logs indefinitely, and logs can be exported or streamed (subscription filters to Kinesis Data Firehose) to S3 for archival.
Step 5 - Protect confidentiality and access
- Encrypt logs with SSE-KMS using a customer managed key, with a key policy that limits who can decrypt. CloudTrail supports SSE-KMS natively, and CloudWatch Logs log groups can be associated with a KMS key.
- Apply least privilege for investigators, for example a dedicated forensic IAM role with read-only access to the log archive.
- Use Service Control Policies (SCPs) to deny cloudtrail:StopLogging, cloudtrail:DeleteTrail, cloudtrail:UpdateTrail, ec2:DeleteFlowLogs, logs:DeleteLogGroup and similar actions for everyone except a break-glass role.
- Monitor for log tampering with EventBridge rules or CloudWatch metric filters and alarms on these API calls. GuardDuty also generates findings such as Stealth:IAMUser/CloudTrailLoggingDisabled.
Step 6 - Capture host and volatile artifacts during an incident
For a compromised EC2 instance, follow the order of volatility:
- Do not terminate the instance. Enable termination protection and set the shutdown behavior to stop rather than terminate.
- Isolate the instance by replacing its security group with a restrictive forensic security group (note that existing tracked connections may persist, so network ACLs may also be needed), detach it from the Auto Scaling group and deregister it from load balancers.
- Tag the instance (for example with an incident ID) to support chain of custody.
- Capture memory first, since it is lost on stop, using tools run through AWS Systems Manager Run Command or a forensic toolkit.
- Capture OS logs through Systems Manager Run Command, or rely on logs already shipped by the CloudWatch agent.
- Take EBS snapshots of all attached volumes, then copy or share them to a dedicated forensic account, and analyze them on an isolated forensic workstation by creating volumes from the snapshots.
- Record instance metadata (AMI ID, IAM role, network interfaces, security groups).
Automation can be built with Step Functions, Lambda and Systems Manager Automation runbooks, often triggered by GuardDuty findings through EventBridge.
Step 7 - Analyze the evidence
- Amazon Athena to run SQL queries against CloudTrail, VPC Flow Logs, ALB and S3 access logs stored in S3.
- CloudTrail Lake for SQL queries over event data stores.
- CloudWatch Logs Insights for interactive queries over log groups.
- Amazon Detective for visual investigation of entities, behavior and relationships.
- Amazon OpenSearch Service or Amazon Security Lake (OCSF normalized data) for broad search and SIEM-style correlation.
4. Key Distinctions to Remember
CloudTrail management events vs data events: Management events are logged by default (90 days in Event History). Data events are not logged by default and must be configured, which matters for S3 object-level exfiltration investigations.
Event History vs trail: Event History keeps only 90 days of management events and cannot be made immutable. A trail delivering to S3 is required for long-term, protected retention.
VPC Flow Logs vs Traffic Mirroring: Flow Logs give metadata only. Traffic Mirroring gives full packets.
Object Lock compliance vs governance mode: Compliance mode cannot be overridden by anyone, including root. Governance mode can be bypassed with the s3:BypassGovernanceRetention permission.
Log file validation vs Object Lock: Validation detects tampering. Object Lock prevents deletion and overwrite. Strong designs use both.
5. Exam Tips: Answering Questions on Capturing Logs as Forensic Artifacts
Tip 1 - Look for integrity keywords: If a question asks how to prove logs were not modified or deleted, the answer is almost always CloudTrail log file integrity validation (digest files and SHA-256 hashes).
Tip 2 - Look for immutability keywords: Phrases like cannot be deleted by anyone, including administrators or the root user point to S3 Object Lock in compliance mode. If an investigation needs preservation of specific objects for an undefined period, choose legal hold.
Tip 3 - Separate accounts win: When asked how to protect logs from a compromised account administrator, choose delivery to a centralized log archive account with restrictive bucket policies, combined with SCPs that block log tampering.
Tip 4 - Prevent logging from being turned off: The preferred preventive control across an organization is an SCP denying StopLogging and DeleteTrail. The detective control is an EventBridge rule or GuardDuty finding with SNS notification. Automatic remediation can re-enable logging with Lambda or AWS Config remediation.
Tip 5 - Preserve before you remediate: Answers that terminate a compromised instance, delete a compromised resource or rebuild before capturing evidence are usually wrong. The correct order is generally: isolate, preserve (memory, logs, snapshots, metadata), then investigate, then eradicate and recover.
Tip 6 - Order of volatility: Memory comes before disk. If an answer stops the instance before capturing memory, the volatile evidence is lost, so that answer is weaker.
Tip 7 - Know default gaps: CloudTrail data events, VPC Flow Logs, S3 server access logs, DNS query logs, ELB access logs and EKS control plane logs are not enabled by default. A question describing missing evidence often hints that the fix is enabling one of these going forward.
Tip 8 - Match the log to the question: Who made an API call - CloudTrail. Which IPs talked to an instance - VPC Flow Logs. What packet content was sent - Traffic Mirroring. Which domains were resolved - Route 53 Resolver query logs. Which objects were read from S3 - CloudTrail S3 data events or S3 server access logs. What a resource configuration looked like at a point in time - AWS Config. Which web requests were blocked - WAF logs. Kubernetes API activity - EKS audit logs.
Tip 9 - Retention questions: Event History is only 90 days. GuardDuty findings are retained 90 days, so export them to S3 through EventBridge for longer retention. For multi-year retention at low cost, use S3 with lifecycle rules to Glacier, or CloudTrail Lake with an extended retention period.
Tip 10 - Least operational overhead: When the question emphasizes minimal effort, prefer managed features: organization trails, AWS Control Tower log archive, CloudTrail Lake, Athena, Detective and Systems Manager Automation runbooks over custom scripts and self-managed servers.
Tip 11 - Encryption and access: If confidentiality of log evidence is mentioned, choose SSE-KMS with a customer managed key and a restrictive key policy. Remember that if the KMS key is disabled or deleted, the logs become unreadable, so protect the key as carefully as the logs.
Tip 12 - Forensic account pattern: For EBS evidence, the correct pattern is to snapshot volumes, share or copy them (re-encrypting with a key the forensic account can use if needed) to an isolated forensic account, and analyze them there on a dedicated instance with no internet access.
Tip 13 - Watch for distractors: Options suggesting manual downloads to a laptop, storing evidence in the same compromised account, relying on CloudTrail Event History for long-term evidence, or using governance mode when the requirement says no one may delete, are typically incorrect.
Tip 14 - Chain of custody: Answers that include tagging resources, recording hashes, restricting access to a small set of investigators, and logging access to the evidence bucket itself (CloudTrail data events on the archive bucket) reflect sound forensic practice.
6. Quick Summary
Enable comprehensive logging in advance, centralize it in a separate account, prove integrity with CloudTrail log file validation and hashes, enforce immutability with S3 Object Lock and versioning, block tampering with SCPs and monitor with EventBridge and GuardDuty, preserve volatile and host data before remediation, and analyze with Athena, CloudTrail Lake, CloudWatch Logs Insights and Detective. In the exam, identify whether the question is about collection, integrity, immutability, retention, access control or analysis, and choose the AWS-native, least-overhead option that preserves evidence before any destructive action.