A leaked AWS key: five questions to ask CloudTrail
It’s a familiar story. An AWS access key, AKIA…, turns up in a public Git repo, a Docker image or a support ticket. Someone deactivates it. Then the SOC gets the inevitable follow-up: “Was it used, and for what?”
Answering that means knowing what to ask CloudTrail. I put my list of questions to the test on the largest public set of attack CloudTrail logs I know of: flaws.cloud, a training site where thousands of players went after a real AWS account between February 2017 and October 2020. Scott Piper (Summit Route) released the anonymized logs in 2020: 1,939,207 events.
In fairness, these “attackers” are mostly CTF players who were handed credentials on purpose. But their tools, habits and mistakes are those of a real attacker who’s just found a key. And a few of them clearly tried to go well beyond the game.
The terrain
Two IAM users whose keys the game exposes, backup and Level6, plus an EC2 instance role whose credentials can be stolen through the metadata service. On the owner’s side: the root account, a few named users and some audit tooling (Security Monkey, notably). IP addresses and account IDs are anonymized, which means you can’t tell an “inside AWS” IP from any other; that’ll matter later.
I loaded the 20 files into SQLite for querying, and replayed SigmaHQ’s 57 AWS rules in Python against every event.

1. Who is using it?
First query: every source IP and user agent tied to the identity. On flaws.cloud, 5,768 addresses used the leaked credentials. For a corporate key you’d hope to find zero, or a handful, each of which becomes an indicator to chase.
The user agent deserves a second look. The AWS CLI and the Python SDKs include the machine’s kernel version, for example Linux/5.6.0-kali1-amd64. In the dataset, 859 IPs have a user agent that gives away a Kali or Parrot host. Anyone who thinks about it can hide this; plenty don’t, and detecting it costs almost nothing:
title: AWS API Call From A Kali Or Parrot Linux Client
id: 1644fdac-6559-42d2-a3c7-7c82ef70262a
status: experimental
description: |
Detects AWS API calls whose user agent carries the kernel version of a Kali or Parrot Linux host,
as written by the AWS CLI and the Python SDKs (for example "Linux/5.6.0-kali1-amd64").
Trivial to change for an attacker who knows about it, but a cheap and very low-noise signal.
references:
- https://summitroute.com/blog/2020/10/09/public_dataset_of_cloudtrail_logs_from_flaws_cloud/
author: PurpleLog
date: 2026-10-17
tags:
- attack.initial-access
- attack.t1078.004
logsource:
product: aws
service: cloudtrail
detection:
selection:
userAgent|re: '(?i)Linux/\S*-\d*(kali|parrot)'
condition: selection
falsepositives:
- Penetration tests and red team exercises, which should be announced
level: medium
My first regex, Linux/\S*-(kali|parrot), missed Linux/5.2.0-2parrot1-amd64: a digit before the distro name. Testing against the data caught it. The fixed version finds all 149,828 events whose user agent contains “kali” or “parrot”, and none of the ordinary user agents in my control list (AWS CLI v2 on Ubuntu, Go SDK, recent Boto3).
2. What did it do first?
For each IP, the very first call. ListBuckets wins by a mile (3,661 IPs), well ahead of RunInstances (697) and GetCallerIdentity (496).
GetCallerIdentity is AWS’s whoami: it returns the account and ARN of whoever’s calling. And it has a quirk the docs spell out: “No permissions are required to perform this operation. If an administrator attaches a policy to your identity that explicitly denies access to the sts:GetCallerIdentity action, you can still perform this operation.” In the dataset, it succeeded 17,128 times out of 17,128.
What that means for a SOC: don’t wait for an AccessDenied on this call, because there won’t be one. But a GetCallerIdentity from an IP never seen before for that identity is often the first trace of the leak. It’s the earliest point at which you can see the attacker, and they don’t know anything about the account yet.
3. Did it probe its permissions?
An attacker who doesn’t know what a key can do will find out. Tools automate this by calling hundreds of read APIs, and every refusal leaves an event with errorCode set to AccessDenied or Client.UnauthorizedOperation.
For each key + IP pair and each hour, I counted distinct denied APIs. On the players’ credentials, 60 one-hour windows go past 50 distinct denied APIs, from 36 IPs; the record is 653 in a single hour. On the account’s legitimate identities, the maximum is 1. That’s where the threshold in this Sigma correlation comes from:
title: AWS API Call Denied
id: ae49359a-dd61-4b17-aa42-6f6f5eb72321
name: aws_cloudtrail_api_call_denied
status: experimental
description: Base rule for the enumeration correlation below. Not meant to alert on its own.
author: PurpleLog
date: 2026-10-17
logsource:
product: aws
service: cloudtrail
detection:
selection:
errorCode:
- 'AccessDenied'
- 'Client.UnauthorizedOperation'
- 'UnauthorizedOperation'
condition: selection
level: informational
---
title: Permission Enumeration With An AWS Access Key
id: 21567798-26e9-40f1-8c32-9d8ebdd706a0
status: experimental
description: |
Detects one access key, from one source IP, denied on at least 50 distinct AWS APIs within an hour,
the footprint of permission brute-forcing tools after a key leak.
references:
- https://summitroute.com/blog/2020/10/09/public_dataset_of_cloudtrail_logs_from_flaws_cloud/
author: PurpleLog
date: 2026-10-17
tags:
- attack.discovery
- attack.t1580
correlation:
type: value_count
rules:
- aws_cloudtrail_api_call_denied
group-by:
- userIdentity.accessKeyId
- sourceIPAddress
timespan: 1h
condition:
field: eventName
gte: 50
falsepositives:
- Cloud security posture scanners running with a deliberately limited role
level: high
The collection passes sigma check with no errors or issues. pySigma’s Splunk backend converts it (bin _time span=1h, then dc(eventName) by key and IP); the Kusto backend doesn’t handle correlations yet. So here’s the hand-written equivalent for Microsoft Sentinel’s AWSCloudTrail table:
// Permission enumeration: one key, one IP, at least 50 distinct denied APIs within an hour
AWSCloudTrail
| where TimeGenerated > ago(1d)
| where ErrorCode in ("AccessDenied", "Client.UnauthorizedOperation", "UnauthorizedOperation")
| summarize DeniedApis = dcount(EventName), Calls = count(), UserAgents = make_set(UserAgent, 5)
by UserIdentityAccessKeyId, SourceIpAddress, UserIdentityArn, Hour = bin(TimeGenerated, 1h)
| where DeniedApis >= 50
One caveat: on a corporate account, a posture scanner running under a deliberately restricted role can produce the same pattern. The flaws.cloud account is small, and I have no numbers from a large one.
4. Did it mint other credentials?
This is the question people forget, and the dataset shows why it matters. With a long-term key (AKIA…), an attacker can call GetSessionToken and get a temporary key (ASIA…) plus a session token. Calls made with that temporary key still carry the IAM user’s name, but no longer the leaked key’s ID.
In the dataset, 235,385 calls by backup and 253,436 by Level6 were made with ASIA keys, more than 1,700 temporary keys in total. Roughly one call in four. An investigation that filters on userIdentity.accessKeyId equal to the leaked key misses all of it. Filter on the IAM user, and look at the two key families separately:
// A key leaked: everything the IAM user did, temporary keys included
let iamUser = "j.doe";
AWSCloudTrail
| where TimeGenerated > ago(30d)
| where UserIdentityUserName == iamUser or SessionIssuerUserName == iamUser
| extend KeyType = substring(UserIdentityAccessKeyId, 0, 4) // AKIA: long-term key, ASIA: temporary key
| summarize Calls = count(), Denied = countif(isnotempty(ErrorCode)), Api = dcount(EventName),
Regions = dcount(AWSRegion), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated),
UserAgents = make_set(UserAgent, 5)
by SourceIpAddress, KeyType
| order by FirstSeen asc
Remediation works the same way. AWS’s docs point out that temporary credentials “are valid until they expire”, anywhere from 15 minutes to 36 hours, and that cutting them off means changing the permissions of the user or role. Deactivating the AKIA key stops new ones from being issued; for the ones already out there, the docs describe deny policies (the AWSDenyAll managed policy, or a condition on aws:userid).
The same reasoning applies to roles. The flaws.cloud instance role, whose session carries the instance ID i-aa2d3b42e5c6e801a, was used from 651 different IPs. An EC2 instance’s credentials have no business showing up from hundreds of addresses. Even with this dataset’s IP anonymization, that number leaves no room for doubt:
// EC2 instance credentials used from several addresses
AWSCloudTrail
| where TimeGenerated > ago(1d)
| where UserIdentityType == "AssumedRole"
| where UserIdentityArn matches regex @"assumed-role/[^/]+/i-[0-9a-f]{8,17}$"
| where SourceIpAddress != "AWS Internal" and not(SourceIpAddress endswith ".amazonaws.com")
| summarize IPs = dcount(SourceIpAddress), IpList = make_set(SourceIpAddress, 10), Calls = count()
by UserIdentityArn
| where IPs > 1
5. Did it try to stay, or to cost money?
Last question: the actions that change something. The credentials handed to players on flaws.cloud have very narrow rights, and it shows: of the 1,838,124 calls made with them, only 337,024 succeeded. Every persistence attempt failed: 33 CreateUser, 40 CreateAccessKey, 21 AttachUserPolicy, 16 ImportKeyPair, two StopLogging and one UpdateTrail. And RunInstances, the cryptominer’s favorite call, was attempted 1,323,100 times from 736 IPs across 16 regions without a single success; more than half of those calls were throttled by AWS on top of that (Client.RequestLimitExceeded).
A denied attempt is still first-class information. It tells you what the attacker wanted to do, and therefore what they’ll try again with a better key.
What SigmaHQ rules see
I replayed SigmaHQ’s 57 AWS rules, plus my user agent rule, over all 1,939,207 events:

Three takeaways. First, lots of noise for little signal: sts_assumerole_misuse fires on every call made with an assumed role, Lambda and audit tooling included (42,315 times), and root_account_usage on all of the owner’s root activity. Both are rated low, rightly so. They’re hunting rules, not alerts. Second, the targeted rules do see the attempts: ec2_import_key_pair_activity, iam_backdoor_users_keys and disable_logging surface the players’ tries, even though every one of them was denied. They don’t filter on errorCode. I think that’s the right call, as long as triage looks at that field first.
Third, imds_malicious_usage fires 2,573 times on the instance’s own identity credentials (aws:ec2-instance), used from 111 IPs. It’s the only SigmaHQ rule in this set that deals with stolen instance credentials, and it only covers that session type. The flaws role attached to the same instance, used from 651 IPs, only trips the generic assumed-role rule, buried among its 42,315 hits.
My five questions, in short
- Who’s using it: source IPs, user agents, first seen.
- What did it do first: often
ListBucketsorGetCallerIdentity, the latter always succeeding. - Did it probe its permissions: dozens of denied APIs per hour.
- Did it mint other credentials:
GetSessionToken,ASIAkeys, roles. Search by user, not by key. - Did it try to stay or cost money: new identities, keys, instances, logging turned off, successful or not.
Number four is the one I see least often in runbooks. In this dataset, it’s also the one hiding a quarter of the activity.
References
- Summit Route (Scott Piper), Public dataset of Cloudtrail logs from flaws.cloud
- AWS, GetCallerIdentity
- AWS, Disabling permissions for temporary security credentials
- SigmaHQ, AWS CloudTrail rules, repository pulled on October 16, 2026
- Microsoft, AWSCloudTrail
- MITRE ATT&CK, T1078.004 Cloud Accounts, T1580 Cloud Infrastructure Discovery, T1552.005 Cloud Instance Metadata API