Sub topic 12
Putting it together: investigating a suspicious change
This chapter walks through one investigation from alert to report, using the pieces from earlier chapters. It assumes you can read a CloudTrail event record, know the difference between Event history and a trail, and have a trail delivering to S3 with log file validation enabled. It also assumes you can use the AWS CLI and read JSON.
The scenario
An alert fires: someone called StopLogging on the trail org-audit-trail. The event looks like this (trimmed):
{
"eventVersion": "1.09",
"userIdentity": {
"type": "IAMUser",
"arn": "arn:aws:iam::123456789012:user/alice",
"accountId": "123456789012",
"userName": "alice"
},
"eventTime": "2026-11-20T09:15:42Z",
"eventSource": "cloudtrail.amazonaws.com",
"eventName": "StopLogging",
"awsRegion": "us-east-1",
"sourceIPAddress": "203.0.113.10",
"userAgent": "aws-cli/2.x",
"requestParameters": { "name": "org-audit-trail" },
"readOnly": false,
"eventType": "AwsApiCall",
"recipientAccountId": "123456789012"
}Turning off the audit trail is a classic step in an attack, because it hides what comes next. It can also be an honest mistake or planned maintenance. The investigation should tell you which one it was, and it should not assume the answer in advance.
The workflow
The dotted line matters. A coverage gap often sends you back to pivot again, using a different data source.
Step 1: Confirm the event
Alerts can be stale, duplicated, or based on a filter that is slightly too broad. Retrieve the original record from a source you trust. Event history is a good choice because it is independent of the trail you are worried about.
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=StopLogging \
--max-results 10This covers management events from the last 90 days in the current Region. Run it in the Region that appears in the alert. Each result holds the full record as a JSON string in the CloudTrailEvent field.
Then check the present state of the trail:
aws cloudtrail get-trail-status --name org-audit-trailLook at IsLogging, StopLoggingTime, StartLoggingTime, and LatestDeliveryTime. If IsLogging is still false, you have an active gap and should restore logging soon (step 6). Do not wait for the full investigation to finish.
Step 2: Identify the actor
Read userIdentity before anything else. The type field changes how you interpret the rest.
| `userIdentity.type` | What it means | What to check next |
|---|---|---|
| `IAMUser` | A long-lived user, possibly using an access key | `userName`, `accessKeyId`, whether MFA was used |
| `AssumedRole` | A role session, from a person, a service, or federation | `sessionContext` for the role and the session name, and who assumed it |
| `Root` | The account root user | Treat as high priority, since the root user is rarely used day to day |
| `AWSService` | An AWS service acting for you | Which service, and which of your resources triggered it |
For an assumed role, the useful question is "who assumed the role?" The role ARN alone does not answer it. Find the AssumeRole or AssumeRoleWithSAML event that created the session and read its caller. Federation events also record the external identity in the session name or attributes.
Also compare the userAgent with what you expect. A person using aws-cli/2.x is plausible for an engineer. A console user agent or an unfamiliar SDK may be worth a second look, but a user agent is only a client-supplied string. Use it as a hint and never as proof.
Step 3: Pivot on identity, key, and IP
One event is a data point. The real picture comes from everything else the same actor did. Each field below is a pivot, and each can lead to a different set of events.
- Identity. Everything done by
alice, or by the same role session. - Access key. If the event used an access key, every event with that key ID, including those made by a different user name after the key was shared or stolen.
- Source IP. Every event from
203.0.113.10, including calls made under other identities.
Event history supports one lookup attribute at a time. For example:
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=Username,AttributeValue=alice \
--start-time 2026-11-20T08:00:00Z \
--end-time 2026-11-20T11:00:00Z \
--query 'Events[].[EventTime,EventName,EventSource,Username]' \
--output tablelookup-events is rate limited and only covers management events, so for combined filters and data events, use CloudTrail Lake or Athena. A Lake query that pivots on the source IP across all identities:
SELECT eventTime, eventName, userIdentity.arn, sourceIPAddress
FROM <event-data-store-id>
WHERE sourceIPAddress = '203.0.113.10'
AND eventTime > '2026-11-20 00:00:00'
ORDER BY eventTimeThe event data store ID takes the place of the table name. If it returns calls from identities that have no business using that address, the problem is probably larger than one user.
To see the shape of activity, such as an unusual burst of IAM calls, reuse the summary query from the querying chapter. Run it for the suspect window rather than the whole month:
SELECT eventName, COUNT(*) AS calls
FROM <event-data-store-id>
WHERE eventTime > '2026-11-20 00:00:00'
AND userIdentity.type = 'IAMUser'
GROUP BY eventName
ORDER BY calls DESC
LIMIT 10Step 4: Build a timeline
Write down the events in time order. Include the minutes before the suspicious call, because preparation often shows up there: ListTrails, GetTrailStatus, DescribeTrails, or permission checks. Include the minutes after it too, because that is the period the attacker wanted hidden.
A useful timeline has these columns:
| Time (UTC) | Actor | Action | Target | Source | Notes |
|---|---|---|---|---|---|
| 09:14 | alice | `DescribeTrails` | all trails | 203.0.113.10 | Recon, or routine checking |
| 09:15:42 | alice | `StopLogging` | org-audit-trail | 203.0.113.10 | Alert trigger |
| 09:16 onward | unknown | unknown | unknown | unknown | Not in the trail, see step 5 |
Keep everything in UTC. CloudTrail times are UTC, and mixing local time zones is a common source of wrong conclusions.
Step 5: Check integrity and coverage gaps
Two separate questions come up here.
Is the evidence trustworthy? Run log file validation across the period. It uses the digest files to detect log files that were modified, deleted, or are missing.
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-20T00:00:00ZExtend --end-time to cover the whole incident, not only the period before it. Validation only works for logs delivered while log file validation was enabled, so it cannot vouch for older logs. Treat any invalid or missing file as a finding. It means someone altered the evidence, or delivery failed for another reason that you still need to explain.
What is not in the trail? After StopLogging, the trail records nothing until logging resumes. That hides the actor's later actions from S3, Lake, and Athena, if those are fed by the same trail. Fill the gap with other sources:
- Event history still holds management events from the last 90 days, whether or not a trail was running, so repeat the step 3 lookups for the gap window.
- Data events, such as S3 object reads, are not in Event history. If the trail was the only place they were recorded, they are lost for that window. Note this clearly in your report.
- Other logs, such as S3 server access logs, VPC flow logs, or service-specific logs, may cover part of the gap.
- A second trail or an organization trail in another account may have kept recording, if you have one.
Step 6: Contain and restore
Restore logging first. It is quick and reversible, and it stops the gap from growing.
aws cloudtrail start-logging --name org-audit-trailThen limit the actor, matching the response to what you found:
- If an access key was used, set it inactive with
aws iam update-access-key --user-name alice --access-key-id <key-id> --status Inactive. Deactivating is reversible, unlike deleting. - For a role session, attach a policy that denies actions for sessions issued before a given time, which revokes older sessions without breaking new ones.
- If the actor was a real person acting in good faith, contact them before changing their access, so you do not disrupt work that was legitimate.
Then check how the change was possible. Why could alice call StopLogging at all? Tighten the permission, and consider a service control policy or an explicit deny on cloudtrail:StopLogging and cloudtrail:DeleteTrail for everyone except a small break-glass role.
Step 7: Document
A short report lets someone else check your reasoning. Include:
- The triggering event, quoted from the original record.
- The actor, with how you identified them and your confidence.
- The timeline, including the gap.
- What validation showed.
- What you did to contain the issue, with timestamps.
- What you could not determine, and what would settle it.
Keep the original event IDs. They let anyone find the same records later.
Common errors
- Searching the wrong Region. Event history is per Region. Global service events, such as IAM, appear in
us-east-1. - Trusting the alert text. Read the source record.
- Stopping at the first identity. The access key or IP pivot often shows a second identity.
- Mixing time zones. Keep everything in UTC.
- Treating gaps as quiet periods. Report the gap and the sources you used to fill it.
- Skipping validation until the end. Run it early, so you know whether you can trust the records.
Exercise
A trail was stopped at 09:15:42Z and restarted at 11:02:10Z. You need to know whether anyone downloaded objects from a sensitive S3 bucket in that window. The trail recorded S3 object-level data events for that bucket. Can you answer from the trail and from Event history? What else would you check?
Show answer
Not from either. The trail recorded nothing between the two times, and Event history holds only management events, not S3 object-level data events. The window is a blind spot for downloads. Check other sources such as S3 server access logs for the bucket, other trails (for example an organization trail in another account), and any application logs. If none exist, report the window as unverifiable instead of reporting no activity.
Exercise
In step 3, why pivot on the source IP address as well as the user name?
Show answer
An attacker may use several identities from one address, or a stolen access key may be used under a different user name. Searching only by user name would miss those calls. Searching by IP finds every identity that used the address, so it shows the full scope of the activity.