Last reviewed: by Dr. Austin Osuide
An attacker who can change your CloudTrail configuration can hide what they do next. Some changes stop the trail outright. Others leave it delivering logs while dropping the events your detections depend on. You need an alert for the changes and a separate check that the records still reach the SOC.
Once an attacker holds credentials that can administer CloudTrail, cutting the logging is a cheap way to cover whatever comes next. ATT&CK tracks it as T1685.002 Disable or Modify Cloud Log. The rule in this guide watches four API calls. StopLogging and DeleteTrail end collection and are hard to miss. PutEventSelectors and UpdateTrail are quieter, because the trail carries on delivering files while a class of events, a Region or a destination goes missing. The rule pages on any successful, unplanned use of those calls against a trail your SOC depends on.
A stopped trail cannot report what happens next, so the guide also builds a check that fires when expected events stop arriving.
Start with an inventory, because the rule cannot tell a serious change from a harmless one until it knows which trails your detections read. Many AWS organisations log through a single organisation trail. The management account or a CloudTrail delegated administrator creates it, and it logs every member account to one S3 bucket. From the management account, in the trail's home Region, run DescribeTrails and GetEventSelectors. Record the trail name and ARN, the home Region, whether it is multi-Region, the bucket, the KMS key, the log file validation setting and the event selectors. Confirm that the selectors include write management events, since every call this guide alerts on is one, and that they do not exclude AWS KMS events if you want the key alerts in step 3.
Load that record into the SIEM as a lookup table with one row per trail. Add any member account trail that a paging detection reads, such as one that carries S3 data events for a team's buckets. A trail that is missing from the table still gets its changes logged for review, but nobody is paged.
An organisation trail limits who can tamper with it. Users in member accounts can see the trail, but they cannot stop it, delete it or change what it logs. Only the management account and the delegated administrator accounts can, so a successful change to the organisation trail came from one of those accounts. Add two more columns to the row: the accounts that can administer the trail, and the automation roles there that are expected to change it, such as your infrastructure pipeline.
Check what already blocks these calls. A service control policy can deny all four calls in member accounts, including a member account that acts as delegated administrator. It has no effect on users or roles in the management account, so no SCP protects the organisation trail from a compromised management account role. Where a deny policy is attached, any attempt from a member account should show as denied. A call that succeeds in one of them means the policy was detached or did not cover the caller.
You do not have to collect anything new or search every log. All four calls are management events that change a resource. A multi-Region organisation trail that logs write management events already records them from each member account, in every Region the account has enabled. If the trail's home Region is an opt-in Region, only member accounts that have enabled that Region send it their activity. If the trail feeds your SIEM, the detection is a filter on a handful of fields over data you already ingest, and it should match very few events. The price is delay. CloudTrail typically delivers log files about 5 minutes after the API call, with no guarantee from AWS, and your ingestion time adds to that.
For a faster signal, add an Amazon EventBridge rule. CloudTrail sends API call events to the default event bus of the account where the call was made, in near real time and on a best-effort basis. A rule with the pattern below can forward the matches to an event bus in your security account, once that bus has a policy allowing the sending accounts. Only the management account and the delegated administrator accounts can change the organisation trail, and for a multi-Region trail AWS requires all four calls to be made in the trail's home Region. Deploy the rule in that Region in each of those accounts. A member account needs the rule only if it owns a trail in your table. The pattern has no errorCode condition, and AWS does not document whether denied calls are delivered to EventBridge, so test a denied call before you rely on it either way. EventBridge only receives these events while the account has a trail that is logging, so stopping an account's only trail can silence this rule as well.
GuardDuty gives you a signal that does not depend on your trails at all. It reads CloudTrail management events through its own stream, which your trail configuration does not affect, and raises the finding Stealth:IAMUser/CloudTrailLoggingDisabled when a trail is disabled. AWS documents a successful deletion or update of a trail, and the deletion of the S3 bucket that stores its logs, as triggers. The documentation does not list StopLogging or a selector change, so test those in your own environment before you rely on the finding for them. The default severity is Low, and a queue that pages on severity will never put it in front of the on-call engineer. Route it by finding type. Because changes to a multi-Region trail are made in its home Region, confirm that GuardDuty is enabled there in the management account and the delegated administrator accounts. If you use a delegated GuardDuty administrator, an EventBridge rule in that account receives findings from the member accounts as well.
Run the SIEM rule as the base, because it covers every account without new infrastructure, and page on the GuardDuty finding alongside it. Add the EventBridge rule if the delivery delay is longer than you can accept for the accounts that can change the organisation trail.
{
"source": ["aws.cloudtrail"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventSource": ["cloudtrail.amazonaws.com"],
"eventName": ["StopLogging", "DeleteTrail", "PutEventSelectors", "UpdateTrail"]
}
}
The pseudo-query below covers the four trail calls. It keeps those calls, drops any record that carries an errorCode, and joins what is left to the table from step 1. The API takes the trail in a Name parameter for StopLogging, DeleteTrail and UpdateTrail and in TrailName for PutEventSelectors, and either can hold a short name or a full ARN. Check how your own records spell those fields before you rely on the join. Run the same query with errorCode present as a second, lower-priority rule for correlation, since a denial still shows that someone tried.
Automation is the main source of noise. Pipelines and account provisioning tools can call UpdateTrail and PutEventSelectors as part of normal work. Suppress a hit only when the calling role is in the trail's list of expected roles and the request matches an approved change in your change system. If the SIEM cannot see that system, let the hit through to a person. Successful calls against a trail in the table page as set out in the bullets below, and a call against any other trail goes to review.
The four calls are not the only way to break the feed. CloudTrail needs permission to write to the log bucket, and AWS states that it cannot deliver logs when the trail's KMS key is disabled or the key policy no longer allows it. Deleting the bucket, removing CloudTrail's permissions from the bucket policy, or disabling the key can stop delivery without touching the trail. CloudTrail keeps trying to deliver to an unreachable bucket for 30 days. An account that is removed from the organisation also loses the organisation trail. The delivery check in step 5 catches all of those after the fact. For an earlier warning, write a second query on the same feed. Match DeleteBucket, PutBucketPolicy and DeleteBucketPolicy where the bucket is the one in your table, DisableKey, ScheduleKeyDeletion and PutKeyPolicy where the key is the trail's key, and the AWS Organizations calls LeaveOrganization, RemoveAccountFromOrganization and DetachPolicy.
trail_ref = coalesce(requestParameters.name, requestParameters.trailName)
FROM cloudtrail_events e
JOIN trail_table t
ON trail_ref = t.trail_arn
OR (trail_ref = t.trail_name AND e.recipientAccountId IN t.admin_accounts)
WHERE e.eventSource = 'cloudtrail.amazonaws.com'
AND e.eventName IN ('StopLogging', 'DeleteTrail', 'PutEventSelectors', 'UpdateTrail')
AND e.errorCode IS NULL
An attacker who can administer CloudTrail can often reach the other detective services too. Deleting a GuardDuty detector or stopping an AWS Config recorder removes a second source of evidence, and losing GuardDuty also removes the trail-independent finding from step 2. Once a detector is deleted, GuardDuty generates no more findings in that Region, so the alert has to read the CloudTrail record of the change. Those calls are management events in the same feed, with an eventSource of guardduty.amazonaws.com or config.amazonaws.com. Their records name no trail, so they need a query of their own. Match the event sources and calls listed below, and join the account to a table that flags production accounts. Use recipientAccountId, and fall back to userIdentity.accountId because recipientAccountId is an optional field.
Both services are set up per account and per Region. A detector exists separately in each Region where GuardDuty is enabled. An account can have one customer managed configuration recorder in each Region, the one you create yourself. Service-linked recorders created by other AWS services are outside this guide. An attacker only has to remove the one in the Region where they plan to work, so do not limit the rule to your main Regions. For the expected state, export the member list and detector settings from the delegated GuardDuty administrator and the recorder status from each account, and generate the table rows from those exports so they stay current.
In an organisation the list of legitimate callers is short. When GuardDuty is managed through AWS Organizations, a member account cannot suspend or disable GuardDuty for itself. The delegated administrator cannot disable a member directly either. It has to disassociate the member account and then delete it, and only after that can the account disable GuardDuty on its own. While the organisation's auto-enable setting is ALL, AWS documents that both calls fail for an account that is still in the organisation. Watch DisassociateMembers and DeleteMembers in the administrator account for that reason, and UpdateOrganizationConfiguration alongside them, because it changes the auto-enable setting.
In production accounts, page on any unexpected success from the page group in the list below, and send the review group to review. When a change turns out to be unapproved, follow the containment order in step 6 and restart the recorder or recreate the detector as part of it. AWS warns that disabling GuardDuty loses its existing findings and configuration.
# Stops detection or recording: page
guardduty.amazonaws.com DeleteDetector, UpdateDetector, UpdateOrganizationConfiguration,
DisassociateMembers, DeleteMembers, StopMonitoringMembers
config.amazonaws.com StopConfigurationRecorder, DeleteConfigurationRecorder
# Narrows or hides output: review
guardduty.amazonaws.com CreateFilter, UpdateFilter
config.amazonaws.com PutConfigurationRecorder, DeleteDeliveryChannel
Every alert above depends on an event arriving, so build a check that pages when the feed goes quiet. On a schedule, call GetTrailStatus for each trail in the table, in the trail's home Region, from the account that owns it. IsLogging, LatestDeliveryTime and LatestDeliveryError tell you whether the trail is running and delivering to its bucket. Page when IsLogging is false or when LatestDeliveryError is set. That field reports only problems with the destination bucket. Treat a delivery time that has stopped advancing as a fault only where API activity is normal, because CloudTrail delivers no log files when no calls are made.
The events land in two places, and both need watching. In the S3 archive, find the newest log file under each account and Region prefix. An organisation trail stores them under the organisation ID, then the account ID, then the Region. In the SIEM, run a scheduled query for the newest CloudTrail event per account and Region. Alert when either falls behind a threshold, and start that threshold at a few multiples of your normal end-to-end delay. When the archive has a recent file but the SIEM has no matching record, the fault is in the ingestion path.
Across hundreds of accounts, most account and Region pairs are silent because nothing runs there. Limit the check to Regions your organisation uses and block the others with a service control policy, so that silence in them is expected. The policy does not bind the management account, so keep that account in the check for every Region. In accounts that are quiet even in active Regions, schedule a harmless write call from a dedicated role so the check always has an event to find.
A recent delivery timestamp says nothing about whether a particular S3 bucket's object events arrived. For that, check for a recent sample of each event class your paging detections read.
The GuardDuty and Config alerts in step 4 share the weakness of every other alert here. If the trail is stopped first, a later DeleteDetector never reaches the SIEM. Add a scheduled reconciliation that calls ListDetectors and GetDetector in GuardDuty and DescribeConfigurationRecorderStatus in AWS Config for each account and Region, compares the answers with the expected state from step 4, and pages on a difference. A missing detector or recorder counts as a difference. Give the scheduled jobs in this step a heartbeat of their own, so that a check that has stopped running is noticed.
AWS Config can catch the bluntest end states. The managed rules cloudtrail-enabled and multi-region-cloudtrail-enabled run periodically. The first reports NON_COMPLIANT when no trail is enabled. The second reports NON_COMPLIANT when no multi-Region trail matches its parameters, or when the trail excludes management events such as AWS KMS events. Their documentation describes no check on data event selectors, log file validation or the trail's KMS key. Because they are periodic, the result arrives some time after the change and does not say who made it.
When the feed does go quiet, CloudTrail Event history in the affected account and Region shows recent management activity. Event history keeps 90 days of management events independently of your trails, which makes it a fallback for the gap, but it cannot recover missing data events or replace the central archive.
Store the raw CloudTrail record with the SIEM alert, because triage needs fields that normalisation often drops. Its userIdentity field identifies the caller and requestParameters holds what was requested, with awsRegion and recipientAccountId for the Region and the receiving account. Check errorCode and errorMessage, and look in responseElements too, because some services report errors there. A denied attempt goes to correlation and does not count as lost coverage. A successful request can still leave the configuration as it was, so read the current configuration before concluding that it changed.
A familiar deployment role is not enough to clear the alert. The session, the target and the intended change all have to match the approved change record. If nothing explains the change, contain it first. For a role, revoke its active sessions in IAM, which denies every credential the role issued before that moment. That control acts on every session of the role at once, and it does not apply to service-linked roles. For an IAM user, deactivate the access keys. Then have the team that owns the trail call StartLogging or put back the previous configuration. StartLogging does not bring back a deleted trail, which has to be created again.
Then preserve the audit evidence and work out which accounts, Regions and event classes lost coverage. The incident lead needs the affected interval and the list of detections that relied on that feed. Once collection is restored, confirm that sample events reach the SIEM.
Replay sanitised records outside production to test the routing. Use an unexpected successful call, a denied attempt, and an approved change to a trail in the table. Each should land in a different triage outcome. Replay only proves the parsing and routing, so also make the real calls against a disposable trail, detector and recorder and confirm that each alert fires end to end. Use UpdateTrail or DeleteTrail to test the GuardDuty finding, since those are the triggers AWS documents. Use a standalone sandbox account for the detector tests, because a member account whose GuardDuty is managed through the organisation cannot disable its own detector. The administrator calls, such as DisassociateMembers, need a test administrator and member pair.
The delivery check needs its own test because it has to fire without an incoming CloudTrail event. Simulate missing ingestion and confirm the page reaches the on-call team.