Sub topic 12
Putting it together: investigating a suspicious change
This chapter assumes you have read the earlier chapters on event records, Event history, trails, log integrity, and querying. You need the AWS CLI and read access to CloudTrail.
The scenario
On 2026-11-20 an alert reports that the trail org-audit-trail stopped logging. You must find out who did it, whether they did anything else, and whether the evidence can be trusted.
A repeatable workflow
Work from the fastest source to the most complete one. Start with Event history, widen with queries, then check the evidence.
Step 1: Find the event
Event history keeps 90 days of management events for the current Region. Search by event name:
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=StopLogging \
--max-results 10Run the search in the Region where the trail's home Region is configured. Event history is per Region, so a search in the wrong Region returns nothing.
Step 2: Read the record
Take the matching event and answer five questions from its fields.
| Question | Field | Value in this case |
|---|---|---|
| Who | `userIdentity.arn` | `arn:aws:iam::123456789012:user/alice` |
| What | `eventSource`, `eventName` | `cloudtrail.amazonaws.com`, `StopLogging` |
| On what | `requestParameters.name` | `org-audit-trail` |
| From where | `sourceIPAddress`, `userAgent` | `203.0.113.10`, `aws-cli/2.x` |
| When | `eventTime` | `2026-11-20T09:15:42Z` |
Also check errorCode. If it is present, the call was denied or failed, and the trail may still be running. The sample event has no errorCode, so the call succeeded.
Step 3: Pivot
One event rarely tells the whole story. Ask what else this actor and this IP address did around the same time. For a short window, Event history works:
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=Username,AttributeValue=alice \
--start-time 2026-11-20T08:00:00Z \
--end-time 2026-11-20T12:00:00ZFor anything older than 90 days, or for data events, query CloudTrail Lake. The event data store ID takes the place of the table name:
SELECT eventTime, eventName, eventSource, sourceIPAddress
FROM <event-data-store-id>
WHERE userIdentity.userName = 'alice'
AND eventTime > '2026-11-20 00:00:00'
ORDER BY eventTimeLook for these patterns:
- Calls from an IP address that Alice has not used before.
- Changes made after the
StopLoggingcall, such as new access keys, policy changes, or bucket policy edits. - Calls made with an access key instead of a console session, which can point to a leaked credential.
Step 4: Validate the evidence
Logs recorded while the trail was stopped do not exist in that trail, so a gap is expected. What you must rule out is that existing files were altered or deleted. Validate the window around the incident:
aws cloudtrail validate-logs \
--trail-arn arn:aws:cloudtrail:us-east-1:123456789012:trail/org-audit-trail \
--start-time 2026-11-01T00:00:00Z \
--end-time 2026-11-21T00:00:00ZThis only works if the trail had log file validation enabled. Report any file that fails validation or is missing as a finding in its own right.
Step 5: Contain and improve
- Restart logging with
aws cloudtrail start-logging --name org-audit-trail. - Disable or rotate the credentials used, and review the permissions that allowed
cloudtrail:StopLogging. - Add an EventBridge rule that alerts on
StopLogging,DeleteTrail, andUpdateTrail, so the next occurrence reaches you in minutes. - Write down the timeline: event times, actors, IP addresses, and what was affected.
Common mistakes
- Searching one Region and concluding nothing happened.
- Stopping at the first event instead of pivoting on the actor and IP address.
- Trusting the logs without running validation.
- Treating an
errorCodeevent as a successful change.
Exercise
A StopLogging event shows userIdentity.type of AssumedRole and a sourceIPAddress you do not recognize. Name two follow-up searches and one check on the evidence.
Show answer
Search for all events from the same source IP address in the surrounding hours. Search for the role's other activity, including later calls that change IAM policies or bucket policies. Then run aws cloudtrail validate-logs for the time range to confirm the delivered log files were not modified or deleted.