On November 28, 2025, Sysdig watched an attacker take test credentials from a public S3 bucket and have their own code running in the victim's Lambda function eight minutes later. Admin access followed in under ten.
That is fast, but it is not unusual. Unit 42 leaked keys to public GitHub on purpose and saw them used within five minutes. Clutch Security measured 6.6 minutes on average.
Most of us have no security team. This post is the setup I would do in an afternoon instead:
- Five read-only commands that show where an account stands
- The AWS services worth switching on, with real prices
- One CloudFormation template that emails you on 20 high-risk CloudTrail events
- How to test the event patterns before you deploy anything
- The four traps that waste an afternoon
Prices are for US East (N. Virginia), read on November 26, 2026.
How the pieces fit
API call -> CloudTrail -> EventBridge rule -> SNS topic -> email (about 5 min) (pattern match) CloudTrail delivers within about 5 minutes of an API call on average, and AWS says that time is not guaranteed. So this pipeline tells you at roughly minute five. Keep that number in mind for the last section.
Step 0: audit what you have
All five commands are read-only.
# 1. Is root locked down? You want RootMFA 1 and RootAccessKeys 0. aws iam get-account-summary \ --query 'SummaryMap.{RootMFA:AccountMFAEnabled,RootAccessKeys:AccountAccessKeysPresent}' # 2. Is there a trail, is it multi-Region, are the log files validated? aws cloudtrail describe-trails \ --query 'trailList[].{Name:Name,MultiRegion:IsMultiRegionTrail,Validated:LogFileValidationEnabled}' # 3. Is GuardDuty on in every Region? 1 is on, 0 is off. for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do echo "$r $(aws guardduty list-detectors --region "$r" --query 'length(DetectorIds)' --output text)" done # 4. Is there an Access Analyzer in this Region? aws accessanalyzer list-analyzers --query 'analyzers[].{Name:name,Type:type,Status:status}' # 5. Is public S3 access blocked for the whole account? aws s3control get-public-access-block \ --account-id "$(aws sts get-caller-identity --query Account --output text)" CloudTrail's free 90-day event history already holds a lot. This is one account's console sign-ins, with the names changed. Two rows are the root user, and nothing on this page tells anyone.
Two results look like failures and are really findings:
- Number 4 returning nothing means no analyzer exists in that Region.
- Number 5 returning
NoSuchPublicAccessBlockConfigurationmeans the account-level block was never set.
Step 1: turn on what AWS already gives you
| Switch | What you get | Cost |
|---|---|---|
| One multi-Region CloudTrail trail | Management events kept in S3 past the free 90 days | First copy free, plus S3 storage |
| GuardDuty in every Region | Threat detection on CloudTrail, VPC flow and DNS logs, no rules to write | Free for 30 days, then $4.00 per million CloudTrail management events and $1.00 per GB for the first 500 GB of flow and DNS logs |
| IAM Access Analyzer | A list of what is shared outside your account | External access findings are free |
| Cost Anomaly Detection | A stolen key usually shows up on the bill first | No additional charge |
| EventBridge rule to SNS | The alerts below | AWS events on the default bus are free |
Create the trail in the console. The docs say all trails created there are multi-Region, and the console sets up the bucket policy for you.
GuardDuty has to be enabled per Region. The Regions you never deploy to are the ones an attacker will use, so enable all of them:
for r in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do aws guardduty create-detector --enable --region "$r" done That loop changes your account, and the 30-day trial starts per Region when you run it. Check the Usage page in the GuardDuty console before the trial ends.
Step 2: the alert template
Save this as aws-security-alerts.yaml.
AWSTemplateFormatVersion: "2010-09-09" Description: Email a team address when a high-risk CloudTrail event happens in this Region. Parameters: AlertEmail: Type: String Description: Address that receives the alerts. Use a shared mailbox, not one person. Resources: AlertTopic: Type: AWS::SNS::Topic Properties: Subscription: - Protocol: email Endpoint: !Ref AlertEmail AlertTopicPolicy: Type: AWS::SNS::TopicPolicy Properties: Topics: - !Ref AlertTopic PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Principal: Service: events.amazonaws.com Action: sns:Publish Resource: !Ref AlertTopic HighRiskApiCalls: Type: AWS::Events::Rule Properties: Description: Logging turned off, new credentials, public exposure, key deletion EventPattern: detail-type: - AWS API Call via CloudTrail detail: eventName: - StopLogging - DeleteTrail - UpdateTrail - DeleteDetector - StopConfigurationRecorder - DeleteFlowLogs - CreateUser - CreateAccessKey - CreateLoginProfile - AttachUserPolicy - UpdateAssumeRolePolicy - AuthorizeSecurityGroupIngress - PutBucketPolicy - PutBucketAcl - DeleteBucketPublicAccessBlock - DeleteAccountPublicAccessBlock - ModifySnapshotAttribute - ScheduleKeyDeletion - DisableKey Targets: - Arn: !Ref AlertTopic Id: email RiskyConsoleSignIns: Type: AWS::Events::Rule Properties: Description: Root sign-ins, and IAM users signing in without MFA EventPattern: source: - aws.signin detail: eventName: - ConsoleLogin responseElements: ConsoleLogin: - Success $or: - userIdentity: type: - Root - userIdentity: type: - IAMUser additionalEventData: MFAUsed: - "No" Targets: - Arn: !Ref AlertTopic Id: email Deploy it in us-east-1 first (see trap 1 below), then confirm the subscription email SNS sends you:
aws cloudformation deploy \ --region us-east-1 \ --stack-name security-alerts \ --template-file aws-security-alerts.yaml \ --parameter-overrides AlertEmail=security@example.com What I verified, and what I did not. The template passes aws cloudformation validate-template, and both event patterns matched the right sample events in the test below. I have not deployed this exact stack to a live account, so I have not watched an email arrive from it. Deploy it to a sandbox account first.
Why these events
| Group | Events | What it means |
|---|---|---|
| Covering tracks | StopLogging, DeleteTrail, UpdateTrail, DeleteDetector, StopConfigurationRecorder, DeleteFlowLogs | Someone is switching off the things that record them |
| Getting in, staying in | Root ConsoleLogin, ConsoleLogin without MFA, CreateUser, CreateAccessKey, CreateLoginProfile, AttachUserPolicy, UpdateAssumeRolePolicy | New credentials or wider permissions |
| Going public | AuthorizeSecurityGroupIngress, PutBucketPolicy, PutBucketAcl, DeleteBucketPublicAccessBlock, DeleteAccountPublicAccessBlock, ModifySnapshotAttribute | A port, bucket or snapshot may now be open |
| Destroying | ScheduleKeyDeletion, DisableKey | A KMS key going away takes its data with it |
AttachUserPolicy earns its place twice. It also fires when AWS quarantines a leaked key, because the quarantine is a policy attached to the user. The policy ARN is in the event's requestParameters.
Some of these are noisy on a busy account. AuthorizeSecurityGroupIngress fires for every rule, not just 0.0.0.0/0. Start with everything, then trim what your own pipeline does every day.
Step 3: test the patterns before you deploy
aws events test-event-pattern checks a pattern against a sample event without creating anything. This is how I tested the sign-in rule:
PATTERN='{"source":["aws.signin"],"detail":{"eventName":["ConsoleLogin"],"responseElements":{"ConsoleLogin":["Success"]},"$or":[{"userIdentity":{"type":["Root"]}},{"userIdentity":{"type":["IAMUser"]},"additionalEventData":{"MFAUsed":["No"]}}]}}' EVENT='{"version":"0","id":"1","detail-type":"AWS Console Sign In via CloudTrail","source":"aws.signin","account":"111122223333","time":"2026-11-26T00:00:00Z","region":"us-east-1","resources":[],"detail":{"eventName":"ConsoleLogin","userIdentity":{"type":"IAMUser"},"responseElements":{"ConsoleLogin":"Success"},"additionalEventData":{"MFAUsed":"No"}}}' aws events test-event-pattern --event-pattern "$PATTERN" --event "$EVENT" # { "Result": true } I ran nine cases across the two rules. Root sign-in, IAM user without MFA, StopLogging and CreateAccessKey matched. An IAM user with MFA, a failed login, a single sign-on session and DescribeInstances did not.
The four traps
1. IAM lives in us-east-1. IAM, STS and CloudFront are global services, and CloudTrail records their events in US East (N. Virginia). A rule in eu-west-1 will never see CreateAccessKey. Root sign-ins land in us-east-1, us-east-2 or us-west-2. Deploy the stack in us-east-1, then in those two, then in every Region you run workloads in.
2. MFAUsed is always No for single sign-on. AWS only sets it for IAM users and root. Without the IAMUser filter, every SSO login emails you.
3. S3 event names differ from the API. The API call DeletePublicAccessBlock appears in CloudTrail as DeleteBucketPublicAccessBlock or DeleteAccountPublicAccessBlock. Match the CloudTrail name.
4. Read-only calls need a different rule state. A rule in the default ENABLED state does not match read-only management events. To alert on something like GetSecretValue, set the rule's state to ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS. You also need a trail that is logging, or none of these rules receive anything.
One more: the docs spell the sign-in detail-type two ways (AWS Console Sign In via CloudTrail and AWS Console Signin via CloudTrail). The pattern above matches on source: aws.signin so it does not depend on either.
If you would rather not maintain rules
AWS shipped two things that cover some of this:
- GuardDuty Custom Detection Rules (September 2026): it launched with 35 prebuilt, opt-in rules on CloudTrail management events, and the console listed 90 when I looked on November 26, 2026. Every rule starts disabled and has a 14-day dry-run mode.
- AWS Security Incident Response: triages your GuardDuty findings and contacts you when one is real. The first 10,000 findings a month are free. It triages findings from other services and does not generate its own.
What this does not solve
You now get an email at about minute five. It is a block of JSON. It does not say whether that CreateAccessKey was your deploy pipeline or a stranger, and at 3 a.m. nobody reads it until morning.
That gap is the real work. Someone has to look at who did it, from where, and what else they did in the same few minutes. Staffing that around the clock takes 4.2 people per seat (168 hours in a week, 40 in a working one), which is about $542,556 a year at the US median analyst wage.
Disclosure: I work on Jutsu, which does that first investigation in software and asks before it acts. The longer version of this post, with the cost comparison and screenshots, is on the Jutsu blog.
Whatever you choose, decide who answers the alert. A rule nobody reads is a log.
What would you add to the event list? I left out RunInstances and PutRolePolicy to keep the noise down, and I am not sure that was right.


